gol2013
gol2013

Reputation: 33

IntelliJ replace text with tag

I need to replace some html file names in my html file with anchor tags, such that:

abc.html
file.html

becomes:

<a href="abc.html">abc.html </a>
<a href="file.html">file.html </a>

I have though of the following regex in find: [a-z-0-9]+\.html and it seems to work, but I don't know what to add in replace. I have tried some answers from here , but they did not work. Can you please help?

Image reference

Upvotes: 0

Views: 140

Answers (1)

horacix
horacix

Reputation: 56

You need to use capturing groups, that then you can refer back to in the replace box..

Capture groups are created adding parenthesis to find: ([a-z-0-9]+\.html)

Then replace would be: <a href="$1">$1 </a>

$1 means the first capture group.

Upvotes: 1

Related Questions