Finding the shortest match

Tool for Search and Replace across multiple files.
Schwager
Posts: 2
Joined: Mon Aug 19, 2013 5:47 pm

Finding the shortest match

Post 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
User avatar
DigitalVolcano
Site Admin
Posts: 1863
Joined: Thu Jun 09, 2011 10:04 am

Re: Finding the shortest match

Post by DigitalVolcano »

You could try this:-

a1.*?\}\r\n

The question mark makes the .* less greedy.
Schwager
Posts: 2
Joined: Mon Aug 19, 2013 5:47 pm

Re: Finding the shortest match

Post by Schwager »

That's it!
Thank you!
Post Reply