Reputation: 1101
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
[^.?]
Upvotes: 0
Views: 134
Reputation: 1101
thanks for your replay,
i modifed the expression
(<(\w+)>#([^#]*)#)
for this (e.g.) 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...
how to fix the regex?
EDIT
ok i find the solution by my self
\s*
final
(<(\w+)>\s*#([^#]*)#)
Upvotes: 1
Reputation: 3802
use the following regex :
<\w+>#[^#]*#
Edit :
Explanation of the expression :
<
: it starts matching from <\w+
: followed by one or more letters>
: 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 #'
Upvotes: 2