[Lazarus] Regex help needed please

ik idokan at gmail.com
Wed Aug 10 17:21:29 CEST 2011


On Wed, Aug 10, 2011 at 18:18, Graeme Geldenhuys <graemeg.lists at gmail.com>wrote:

> Hi,
>
> I'm fairly new to regex. I know that the * is a greedy match. This is
> currently giving me undesired results. How do I rewrite the regex below
> so it will match up to the first } symbol it encounters.
>
> To put this in context, I'm writing a regex based syntax highlighter.
> Here is sample code I am having trouble with:
>
>   function MyFunc: {$ifdef FPC}longword{$else}word{$endif};
>
>
> The following regex matches the first { symbol up until the last }
> symbol. :-(  I obviously want it to stop at the first } it encounters.
>
> This is the regex I'm currently using:
>
>    \s*\{\$.*\}
>

Try this:
\{.*[^\}]\}



>
>
> Any regex wizards that could help me here?
>
> Regards,
>  - Graeme -
>
> --
> fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
> http://fpgui.sourceforge.net/
>
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110810/de5c3599/attachment-0003.html>


More information about the Lazarus mailing list