I've been struggling to make a regular expression work properly: I need it to match anything that starts with
__(' or __("
and ends with
') or ")
I attempted using
/__\(['"][^']*['"]\)/g and /__\(['"].*['"]\)/g
but they both encounter issues when faced with this example text:
text that should not match
__('all text and html<a href="#">link</a> that should match') text that should not match __('all text and html<a href="#">link</a>')
__("all text and html<a href="#">link</a>") text that should not match __("all text and html<a href="#">link</a>")
other text that should not match
Which RegExp is the winning one?