[PLUG] Regex condition match problem

Colin Kuskie ckuskie at dalsemi.com
Tue Jun 29 13:51:02 UTC 2004


On Tue, Jun 29, 2004 at 01:25:55PM -0700, lbrigman at fcpa.fujitsu.com wrote:
> >On Tue, Jun 29, 2004 at 09:54:26AM -0700, lbrigman at fcpa.fujitsu.com wrote:
> >> 
> >> Actually I'm doing this with the regex functtions that is include in
> >> the QT 3.x library/framework.
> 
> >Then why not try this:
> 
> >/^("[^"]+")\s*(\S+)?\s*("[^"]+")?/
> 
> >^                               Beginning of line
> >("[^"]+")               Find a bunch of characters that aren't quotes 
> surrounded by quotes
> >\s*                             Optional whitespace, in case you only 
> have 1 argument on the line
> >(\S+)?                          Optional second argument of 
> non-whitespace
> >("[^"]+")?              Quoted sequence, optional
> 
> That almost got what I wanted.  Thanks, it pointed me in the direction I 
> needed.
> I didn't want the quote returned as part of the selected string.
> 
> Here is what I will be using:
> 
> /^"([^"]+)"\s*(\S+)?\s*"?([^"]+)?/
> 
> I didn't connect that the ? was to be after the expresion to make it 
> optional.

If you're going to use regular expressions, I'd recomment getting a
copy of Jeff Friedl's book, Mastering Regular Expressions.  It will
help your understanding a lot.

Also, the perlre and perlretut manpages do a good job of explaining
regular expression, but as Randal pointed out, they're perl specific.

Colin




More information about the PLUG mailing list