c# - regular expression not matching mutiple results, when matching against a single line -
Does anyone work with regular expressions? ..
I am running the following RegEx:
On the following text:
& lt; Text & gt; Initial Text & lt; / Text & gt; & Lt; Comment & gt; & Lt; Users & gt; 6 & lt; / User & gt; & Lt; Date & gt; 635277984371174139 & lt; / Date & gt; & Lt; Body & gt; Recorded clinical data: 0132.00 MD Dud & lt; / Body & gt; & Lt; / Comment & gt; & Lt; Comment & gt; & Lt; Users & gt; 6 & lt; / User & gt; & Lt; Date & gt; 635277984559612059 & lt; / Date & gt; & Lt; Body & gt; Recorded clinical data: 0132.00 Managing Director ii & lt; / Body & gt; & Lt; / Comment & gt; & Lt; Comment & gt; & Lt; Type & gt; Complete & lt; / Type & gt; & Lt; Users & gt; 6 & lt; / User & gt; & Lt; Date & gt; 635277984668163579 & lt; / Date & gt; & Lt; Body & gt; Kkk & lt; / Body & gt; & Lt; / Comment & gt;
However, it results in only one match ... I would expect 3 matches..is anyone have any idea?
< P> / li>
Your regex is failing because *
is a greedy quandafaire. This means that it will "eat" as much as possible: this is the first & lt; Body & gt;
will match the last one, in which the inside will be included. What do you want
& lt; Body & gt; *? & Lt; / Body & gt;
?
Quantifier makes non-greedy, it will be closed in the first match.
You should edit your question, because your HTML is currently unreadable.
Comments
Post a Comment