[nzlug] Hard regexp question

Edwin F edf825 at gmail.com
Sun Aug 5 18:05:08 NZST 2007


On 8/5/07, Eliot Blennerhassett <linux at blennerhassett.gen.nz> wrote:
> Regexps can be translated into English...
> The / / marks the start and end of the expression
>
> /"(?: |(.+?))"/
>
> I'll leave it to the OP to translate this one (i.e. I dont get it)
>

Hah, fair enough.

(.+?) will match anything and return it.
( |(.+?)) will match [space] or anything and return it in $1 always,
and $2 if it's not a space.
(?: |(.+?)) will match [space] or anything, but will only return
not-space in $1.
"(?: |(.+?))" is same as above surrounded by quotes.


~ed.



More information about the NZLUG mailing list