Mark H
Mark H

Reputation: 259

Returning values from multiple options in Regex

I am searching for specific terms in a block of text only when they are surrounded by other 'qualifying' terms. I have made a regex where each of those qualifying terms is an option:

(?<QUALIFY_A>(A\s(?<TERM>(Hi|Bye)))|(?<QUALIFY_B>B\s(?<TERM1>(Hi|Bye)))|(?<QUALIFY_C>C\s(?<TERM2>(Hi|Bye))))

http://regex101.com/r/xR0uA9

So far this behaves as I expect as it finds the first match of the term when preceded by the qualifying expression. However Ideally I'd like to get each one returned, in other words not have the regex quit once matched. I realize if I just had one option I could do /1/2 to get multiple matches to the one option but in this case trying to get multiple matches to different options.

Upvotes: 1

Views: 44

Answers (1)

aelor
aelor

Reputation: 11116

try putting g in the modifier box you can see on the right hand side of the regex

Upvotes: 1

Related Questions