<div dir="ltr">On Wed, Aug 10, 2011 at 18:18, Graeme Geldenhuys <span dir="ltr"><<a href="mailto:graemeg.lists@gmail.com">graemeg.lists@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I'm fairly new to regex. I know that the * is a greedy match. This is<br>
currently giving me undesired results. How do I rewrite the regex below<br>
so it will match up to the first } symbol it encounters.<br>
<br>
To put this in context, I'm writing a regex based syntax highlighter.<br>
Here is sample code I am having trouble with:<br>
<br>
function MyFunc: {$ifdef FPC}longword{$else}word{$endif};<br>
<br>
<br>
The following regex matches the first { symbol up until the last }<br>
symbol. :-( I obviously want it to stop at the first } it encounters.<br>
<br>
This is the regex I'm currently using:<br>
<br>
\s*\{\$.*\}<br></blockquote><div><br>Try this: <br></div><div>\{.*[^\}]\} <br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
<br>
Any regex wizards that could help me here?<br>
<br>
Regards,<br>
- Graeme -<br>
<br>
--<br>
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal<br>
<a href="http://fpgui.sourceforge.net/" target="_blank">http://fpgui.sourceforge.net/</a><br>
<font color="#888888"><br>
<br>
--<br>
_______________________________________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a><br>
</font></blockquote></div><br></div>