Multi line regex search matches more than i want

Tool for Search and Replace across multiple files.
Post Reply
User avatar
Marcel

Multi line regex search matches more than i want

Post 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
User avatar
Daniel Powell

Post by Daniel Powell »

Make it non-greedy like so
<a><b>Test1</b>.*?</a>

or to match both:

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

Post by Marcel »

Daniel,

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

Kind regards,

Marcel
Post Reply