我有这个元标记:
<meta name="description" content="Measure you passion fort ârt in the name of ÖmÈ™r"/>
所以我写了一个很好的正则表达式来查找包含变音符号/符号的所有元标记描述:
<meta name="description".*[ÖÈ™;#&îÎ]+.*?>
我的问题是这个词中有太多的符号和变音符号。我应该在方括号中添加数百个。
我的问题:对于那些太多的变音符号和符号,有没有简短的版本?我需要一个替换括号中所有符号的公式。
答案 0 :(得分:0)
您可以尝试使用以下正则表达式匹配<meta>
属性中包含变音符号/符号的content
标记:
^<meta name=".*?" content=".*(?=[ÖÈ™#&îÎ]).*?".*>$
如果您从未在Regex模式下使用Notepad ++中的find / replace,那么现在是时候学习了。查找和替换对话框可以选择在正则表达式模式下执行查找/替换,因此您应该选择此选项。而不是从Notepad ++中获取屏幕截图,正则表达式的简单演示可能更有用,q.v。以下链接。
在这里演示:
正则表达式中唯一可能有点令人困惑的部分是正向前瞻(断言),它检查content
属性中是否存在变音符号/符号:
content=" match content="
.* match any number/type of characters
(?=[ÖÈ™#&îÎ]) assert that at some point inside content, a diacritic/symbol
occurs once
.*?" again match any number/type of characters,
until the first closing quote