nicwhitts
nicwhitts

Reputation: 310

Regex for matching every occurrence of text between two characters, only between specific characters

Here's an example

I would like to regex match any text between quotes ''

I want this match:

foo('text1', 'text2', 'text3' ....)

I don't want to match:

bar('text1', 'text2', 'text3' ....)

I don't want to match

'text1'

So i wanted the match the text1 text2 text3 ..etc.. only when between foo(). Matching only the text between the quotes"" and ignore the rest.

Upvotes: 0

Views: 81

Answers (1)

vks
vks

Reputation: 67968

 \bfoo\(\K|\G(?!^)'([^')]*)'[^')]*

You can try this,Grab the matches.

See demo.

https://regex101.com/r/YG5D42/1

Upvotes: 2

Related Questions