0

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.

1 Answer 1

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

You can try this,Grab the matches.

See demo.

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

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! That works perfectly in the demo. But it's not working for my specific use case. Do regex expressions usually have a 'single' matching expression? My guess is because of multiple matches its getting somewhat confused. Idk though
@nicwhitts which language are you using ? Why isnt it working? Any errors
Im actually trying to set the config for tailwind intellisense: github.com/tailwindlabs/tailwindcss-intellisense But using the emacs lsp-mode: (lsp-register-custom-settings '(("tailwindCSS.experimental.classRegex" ["[']([^']*)[']"])))` Here's a demo of this expression that works: regex101.com/r/BE6cc8/1 But as you can see it will match any occurrence of '' quotes. Id like to restrict to just tw.style('') like in the demo. Im pretty new to lisp and emacs so im guessing there's something going wrong between the lsp-mode config and tailwind intellisense config.
not sure if \K or \G is supported or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.