[Lazarus] Regex help needed please

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Aug 10 17:18:44 CEST 2011


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*\{\$.*\}


Any regex wizards that could help me here?

Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/





More information about the Lazarus mailing list