正则表达式选择两个字符之间的所有内容? [英] RegEx to select everything between two characters?
本文介绍了正则表达式选择两个字符之间的所有内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个正则表达式来选择两个字符之间的所有内容.
I am trying to write a regex that selects everything between two characters.
例如,当正则表达式遇到 '§'
我希望它选择 '§'
符号之后的所有内容,直到正则表达式遇到一个';'
.我尝试了后视和前视,但它们并没有真正做到这一点.
For example, when the regex encounters a '§'
I want it to select everything after the '§'
sign, up until the point that the regex encounters a ';'
. I tried with a lookbehind and lookahead, but they don't really do the trick.
例如 " § 1-2 bla; "
应该返回 " 1-2 bla"
.
任何帮助将不胜感激!
推荐答案
怎么样
"§([^;]*);"
§
和 ;
之间的选定字符可作为匹配组 1.
The selected characters between the §
and ;
are available as match group 1.
这篇关于正则表达式选择两个字符之间的所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文