In regular expressions, the brackets ((
and )
) are actually reserved characters so you will need to escape those. So this regex should do the trick: _\\(\"(.*)\"\\)
. However, you also stated that you wanted to find words which must begin with my(
and must end with ")
. So you will need to add anchors like so: ^my\\([\"'](.*)[\"']\\)$
. This should match any string which starts with my("
or my("'
and ends with ")
or ')
.
The ^
and $
are anchors. The ^
will instruct the regex engine to start matching from the beginning of the string and the $
will instruct the regex engine to stop matching at the end of the string. If you remove these anchors, the following would be considered as matches: foo my('...') bar
, my("...") bar
, etc.
This however will make no distinction and will match also strings like my("...')
and my('...")
.