[Israel.pm] regex questions

Yossi.Itzkovich at ecitele.com Yossi.Itzkovich at ecitele.com
Mon Jul 19 06:23:26 PDT 2004





Hi,

A guy here asked me a question, I know how to answer it in the long way,
but please help find something nicer.

We have a text containing lines such as:

[DBACBNav]
[DBACB]
[DBZXYNav]
[DBZXY]
..
..

We would like to capture the string that comes after "DB" but without the
"Nav" - if it exists.

(The best we came with was :  /\[DB((.*?)Nav|(.*?))\]/ ,  but then if we
have "Nav", then we have ti use $2 else we have to use $1   Ichs...)

Yossi




More information about the Perl mailing list