How to replace the
example:
_e("Full Implementation")
find:
_e\("(?:^\\"]+|\\.)*"\)
replace with:
_e("$1", “my_theme”)
As is, the $1 is just being replaced with nothing, but I would like it to be the content between the quotes
How to replace the
example:
_e("Full Implementation")
find:
_e\("(?:^\\"]+|\\.)*"\)
replace with:
_e("$1", “my_theme”)
As is, the $1 is just being replaced with nothing, but I would like it to be the content between the quotes
You are not capturing a group-1. Try this
_e\("(^\\"]+|\\..*)"\)
but I’m not sure what you are trying to achieve with the backslashes, dots, etc.
I don’t know if it meets your requirement, but this regex will find the contents inside the brackets:
_e\("(.*?)"\)
replace with:
_e\("$1", "my_theme"\)
Leads to:
_e("Full Implementation", "my_theme")
thanks both! I just copied this from somewhere as an example of grabbing a text string.
What needs to be done exactly to ‘capture’ a group?
You have to surround them by round brackets.
E.g.:
(.*?)\.(.*)
Two capture groups.
Let’s say you have a Windows file named “file.xml”
Replacing by $1$2 would lead to:
“filexml”
To clarify, using the ?: after the ( tells the parser that you want this set of parentheses to be non-capturing. Parentheses capture the matched text by default.