sinrise
sinrise

Reputation: 391

RegEx match string but not if string comes after

I'm doing a find/replace and but I have already made a few changes the slow way. I want to use regex to replace the rest but make sure I don't replace ones I've already done. So, I need it to match 1 but not 2. The end result will be replacing all instances that look like 1 with 2. The -icon can be anything

1: <span class="glyphicons icon">
2: <span class="glyphicons glyphicons-icon">

More examples:

<span class="glyphicons hand">
<span class="glyphicons flower">
<span class="glyphicons bucket">
<span class="glyphicons glyphicons-stone_head">
<span class="glyphicons glyphicons-decapitated-corpse">

I need to replace the first 3 examples but not the last 2. The application is quite large so I'd really like to be able to do this with one 'replace all'.

Upvotes: 0

Views: 60

Answers (1)

Javier Conde
Javier Conde

Reputation: 2593

Assuming icon can be any word, I'd try replacing glyphicons\s([A-Za-z]+)" by glyphicons glyphicons-$1".

Upvotes: 1

Related Questions