Alternation not working?

A swapping-ground for Regular Expression syntax

Alternation not working?

Postby renamer2000 » Wed May 16, 2012 12:50 pm

Hi,

I'm using the Command Tool and have problems with this regular expression:

Code: Select all
BRC32.exe /PATTERN:"*.jpg *.tif *.tiff *.png *.gif" /REGEXP:^(05|37|91)([0-9]{4})([0-9]{2})([0-9]{2})$:\1\2xx\4


The expression is working in the utility and a regexp tester validates it.
The command line says that 37 is not a function. I can remove 37, 91 and the pipes and it is working.

Is it a bug in the Command Tool?
renamer2000
 
Posts: 1
Joined: Wed May 16, 2012 12:25 pm

Shell-Special Chars must be quoted

Postby truth » Tue Aug 06, 2013 5:49 pm

The error is from DOS trying to pipe/output to an executable named '37' (which doesnt exist)

Arguments with pipe-symbols, redirects, spaces, etc must be quoted away from the DOS-shell
Enclose your /REGEX argument within double-quotes to reserve the text-within specifically for BRC
Not always necessary, but a good habit to develop

Examples that suffice:
/REGEXP:"^(05[|37|91)([0-9]{4})([0-9]{2})([0-9]{2})$:\1\2xx\4"
"/REGEXP:^(05[|37|91)([0-9]{4})([0-9]{2})([0-9]{2})$:\1\2xx\4"

Note that ^ must also be within double-quotes on NT versions of DOS
Otherwise DOS uses it, much like BRU uses \ to precede NextLiteralCharacter
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay


Return to Regular Expressions