Page 1 of 1

Multi line regex search matches more than i want

Posted: Sun Mar 13, 2011 4:30 am
by Marcel
I want to search items spread over multiple lines in a XML file. The number of lines that will match the search can vary. If i use "Dot matches newline" TextCrawler selects everything till the last match.
Example:
<a><b>Test1</b>
abc
def
</a>
<a><b>Test2</b>
ghi
jkl
mno
</a>
If i search <a><b>Test1</b>.*</a> TextCrawler matches till the last </a> while i want to match till the first occurence of </a>.

Is it possible to use TextCrawler this way?

Thank You and kind regards,

Marcel

Posted: Wed Mar 16, 2011 7:52 pm
by Daniel Powell
Make it non-greedy like so
<a><b>Test1</b>.*?</a>

or to match both:

<a><b>[\s\w]+?</b>.*?</a>

Posted: Tue Mar 22, 2011 3:59 am
by Marcel
Daniel,

Thank You very much!
I didn't knew the ? operator could help...

Kind regards,

Marcel