Closed Alexufo closed 1 year ago
Seems to be a duplicate of #2031.
@Alexufo https://stackoverflow.com/questions/19913667/javascript-regex-global-match-groups take a look at this
@Alexufo https://stackoverflow.com/questions/19913667/javascript-regex-global-match-groups take a look at this
thanks, but I wrote about different behavior site vs any js playground
@Alexufo
The difference lies in the function utilized. It's still javascript, but because javascript is an oddball at times, you get a different return although you use the same regex and flags.
You can still isolate the full match (without the individual groups) from the other functions' return as well if that's all you're after. But if that were the case, then why use a capturing group at all? If you need to group things to make them optional you can use a non-capturing group (?:optional)?
.
Hope this helps!
regex101 does not utilize the
match
function of javascript. Instead you should use eitherexec
ormatchAll
.
Originally posted by @firasdib in https://github.com/firasdib/Regex101/issues/2031#issuecomment-1494222022
g modifier does not work as in a browser
Expression:
\[qr:(.*)?\]
Test string:ert et [qr:4] tertert er
Example:Screenshot from playground![image](https://github.com/firasdib/Regex101/assets/1562329/12144419-bcf0-4c88-b1e4-f0a2d4b21339)
G - modifier must be removed from expression to get string "4" in [1] group in real case.