Page 1 of 1

Finding the shortest match

Posted: Mon Aug 19, 2013 5:55 pm
by Schwager
Hi!
I would like to replace

a1 {
someting
}

in the text

a1 {
someting
}
a2{
someting
}
a3 {
someting
}


The expression "a1.*\}\r\n" does find all until the last }
How can I get the shortest match?
Thanks

Re: Finding the shortest match

Posted: Wed Aug 21, 2013 9:16 am
by DigitalVolcano
You could try this:-

a1.*?\}\r\n

The question mark makes the .* less greedy.

Re: Finding the shortest match

Posted: Wed Aug 21, 2013 11:57 am
by Schwager
That's it!
Thank you!