davidcondrey
davidcondrey

Reputation: 35983

Textmate Find regex, Replace wild

In I can use the syntax (.*) to find both lines in the below use case:

<span class="class1"></span>
<span class="class2"></span>

Now I want to append more code to each of them so my find query is span class="(.*)" and my replace query is span class="(.*)" aria-hidden="true" which i had hoped would result in this:

<span class="class1" aria-hidden="true"></span> 
<span class="class2" aria-hidden="true"></span>

but it actually resulted in this:

<span class="(.*)" aria-hidden="true"></span>
<span class="(.*)" aria-hidden="true"></span>

Using find/replace (not using column selection which would work for this example but not for the actual situation) is it possible to maintain the area matched by regex in the replace action with a representative wild character or something?

Upvotes: 1

Views: 184

Answers (2)

Avinash Raj
Avinash Raj

Reputation: 174716

Change your replace query as,

span class="$1" aria-hidden="true"

$1 would refer the characters which are present inside group index 1.

Upvotes: 2

vks
vks

Reputation: 67968

(<span class="[^"]*")

Try this.Replace with $1 aria-hidden="true".See demo.

http://regex101.com/r/wQ1oW3/22

Upvotes: 1

Related Questions