The regex is greedy meaning it will capture as many characters as it can which fall into the .*
match. To make it non-greedy try:
this(.*?)test
The ?
modifier will make it capture as few characters as possible in the match.
More Related Contents:
- Awk – replace coumn 2 in table 1 from coumn 2 in table 2 based on matching data in column 1 (common between tables)
- How do I match any character across multiple lines in a regular expression?
- How do you match only valid roman numerals with a regular expression?
- Regex to match string containing two names in any order
- Validating IPv4 addresses with regexp
- Regular expression pipe confusion
- Find CRLF in Notepad++
- What flavor of Regex does Visual Studio Code use?
- Jmeter extracting fields/parsing JSON response
- How to back reference “inner” selections ( () ) in a regular expression?
- Regular expression – PCRE does not support \L, \l, \N, \P,
- mod_rewrite: replace underscores with dashes
- Multiline regex to match config block
- Remove ‘index.php’ from URL with .htaccess
- Negative look-ahead in Go regular expressions
- Regex Until But Not Including
- How to validate a user name with regex?
- Match at every second occurrence
- What does ‘\K’ mean in this regex?
- regular expression capture nth match
- What regex will match every character except comma ‘,’ or semi-colon ‘;’?
- Regex that matches integers in between whitespace or start/end of string only
- Can I use Perl regular expressions to match balanced text?
- replace a unknown string between two known strings with sed
- Match Sequence using RegEx After a Specified Character
- Nginx location “not equal to” regex
- How to escape dollar sign ($) in a string using perl regex
- Remove everything except a certain pattern
- How does the ? make a quantifier lazy in regex
- How does \b work when using regular expressions?