I'm using IntelliJ IDEA's find and replace tool:
My regex: <h2>(?<title>.*?)</h2>
I'd like to use my named capture group in the replace string. I know I can use $1
to refer to the first capture group, but I'd like to use its name.
I've tried to no avail:
$title
$<title>
$'title'
$"title"
$(title)
$[title]
$['title']
$["title"]
$("title")
$('title')
$[<title>]
$['<title>']
$["<title>"]
$('<title>')
$("<title>")
$<"title">
I stumbled on the solution to this while trying to use a named capture group in IntelliJ. I haven't been able to find documentation on it.
The official documentation now shows how this is done (thanks @Pang):
$n
e.g. find: <h2>(.*?)</h2>
replace: $1
.${<name>}
e.g. find: <h2>(?<title>.*?)</h2>
replace: ${title}