Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
([a-z ]*)characters
/
gi
Input 1
1
New
this is a test string that doesn't match anything? Why? Well, it misses the magical word. this is a test string that doesn't match any characters? Funny huh? ' isn't within the character group, so the capture group starts after it. Try adding ' to the character group! This time, however, I'm going to tell you much about characters. Not just characters, but interesting characters! I can even talk about characters that meet other characters. This is a great example of capture groups. Since . and , aren't within the character group, they aren't matched. However, since we're searching for multiple matches, each is matched individually. the last line, however has 2x "characters" and since the ? is missing behind *, * is greedy and ends at the last occurance of "characters", not the first. Add a ? after * and see what happens. Now change * into + and "characters" will be ignored, since " isn't within the capture group. One last thing, see the match information to the right? Those are captured by the capture groups and can be extracted from the string easily.
Extraction
this is a test string that doesn't match anything? Why? Well, it misses the magical word. this is a test string that doesn't match any characters? Funny huh? ' isn't within the character group, so the capture group starts after it. Try adding ' to the character group! This time, however, I'm going to tell you much about characters. Not just characters, but interesting characters! I can even talk about characters that meet other characters. This is a great example of capture groups. Since . and , aren't within the character group, they aren't matched. However, since we're searching for multiple matches, each is matched individually. the last line, however has 2x "characters" and since the ? is missing behind *, * is greedy and ends at the last occurance of "characters", not the first. Add a ? after * and see what happens. Now change * into + and "characters" will be ignored, since " isn't within the capture group. One last thing, see the match information to the right? Those are captured by the capture groups and can be extracted from the string easily.