c# - Regex skipping matches -
i trying select multiple matches in string looks like:
123
blah
end
45
blah
end
ideally return 2 matches of starting digit sequence , ending end string. using following:
regex splitter = new regex(@"^\d{2,3}(.*)end", regexoptions.singleline); foreach (match res in splitter.matches(content)) { console.writeline(res.tostring()); }
however above pattern returning entire input string in 1 match. have feeling 'singleline' option. doing wrong?
change *
quantifier lazy form (with (.*?)
syntax). @ moment attempts match many symbols in string possible - , succeeds in doing that, of course, have several blocks ending end
.
with ?
added, engine attempt match pattern few symbols possible, finishing (.*?)
match right before first end encounters.
Comments
Post a Comment