Frage

How can you use Aptana's search and replace RegEx functionality to replace lots of instances of something, but not change the bit the regex found if that makes sense? Here's an example, I have several inputs:

<input type="text" name="test[]" id="test-1">
<input type="text" name="test[]" id="test-2">

and so on... So in the search I put <input type="text" name="test\[]" id="test-[0-9]+"> and it will find all instances of the input with that name, regardless of the number in the ID. But now I want to wrap div's around each input. How can I use replace so I have <div> tags around the input, but not change the ID?

I tried using <div><input type="text" name="test\[]" id="test-[0-9]+"></div> in the replace but then I end up with:

<div><input type="text" name="test[]" id="test-[0-9]+"></div>
<div><input type="text" name="test[]" id="test-[0-9]+"></div>

on every line. How can I leave the ID alone?

War es hilfreich?

Lösung

You only need to use <div>$0</div> as replacement string, where $0 represents the whole match result.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top