RegEx匹配字符串,但如果字符串在

时间:2015-11-05 00:24:19

标签: regex

我正在进行查找/替换,但我已经做了一些缓慢的改动。我想用正则表达式替换其余部分,但要确保我不替换我已经完成的部分。所以,我需要它匹配1而不是2.最终结果将替换所有看起来像1的实例2. -icon可以是任何东西

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

更多例子:

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

我需要替换前3个示例而不是最后2个示例。应用程序非常大,所以我真的希望能够用'替换所有'来做到这一点。

1 个答案:

答案 0 :(得分:1)

假设icon可以是任何字词,我会尝试将glyphicons\s([A-Za-z]+)"替换为glyphicons glyphicons-$1"