[英]RegEx matching - stop first matching
this string must be checked, with regex ... 必须使用正则表达式检查此字符串...
<u>str<b>#u #bold<em>#u b #ital<strike>#u b em #ic stri</strike>ng</em>also(bold)</b></u><u>str<b>#u #boldalso(bold)</b></u>
This is the regex 这是正则表达式
[^.?]>#(.*?) #
The matching must be contained follow values 匹配必须包含以下值
<b>#u #
<em>#u b #
<strike>#u b em #
<b>#u #
but only was matched 但只有匹配
b>#u #
m>#u b #
e>#u b em #
b>#u #
what is wrong? 怎么了? i think this expression-part must be updated
我认为此表达部分必须更新
[^.?]
use the following regex : 使用以下正则表达式:
<\w+>#[^#]*#
Edit : Explanation of the expression : 编辑:表达式的说明:
<
: it starts matching from < <
:从<开始匹配 \\w+
: followed by one or more letters \\w+
:后跟一个或多个字母 >
: and then closing > >
:然后关闭> #
: followed by # #
:后跟# [^#]*
: this will match just before of # [^#]*
:这将与#之前匹配 #
: and then # #
:然后# so 所以
<\w+># [^#]* # Final Match
---------------------------------------------------------
'<b>#' 'u ' '#' '<b>#u #'
'<em>#' 'u b ' '#' '<em>#u b #'
'<strike>#' 'u b em ' '#' '<strike>#u b em #'
'<b>#' 'u ' '#' '<b>#u #'
thanks for your replay, 感谢您的重播,
i modifed the expression 我修改了表达式
(<(\w+)>#([^#]*)#)
for this (eg) string 为此(例如)字符串
<strike> #u #String:Underline-Strike-1<b>#u strike #String:Underline-Strike-Bold </b></strike><strike>#u #String:Underline-Strike-2</strike>
it was all matched, but not for 全部匹配,但不适合
<strike> #u #String:Underline-Strike-1
the WHITESPACE after ">" is the problem... “>”之后的WHITESPACE是问题...
how to fix the regex? 如何修复正则表达式?
EDIT 编辑
ok i find the solution by my self 好吧,我自己找到解决方案
\s*
final 最后
(<(\w+)>\s*#([^#]*)#)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.