[mapserver-dev] Bug(s) with REGEX on 5.6.8?

Stephen Woodbridge woodbri at swoodbridge.com
Thu Mar 1 11:30:27 EST 2012


Hi All,

This is beginning to look like a bug in expression handling on 5.6.8 
and/or the documentation.

/u/www/cgi-bin/mapserv -v
MapServer version 5.6.8 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP 
OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV 
SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT 
SUPPORTS=WFS_SERVER SUPPORTS=RGBA_PNG INPUT=EPPL7 INPUT=POSTGIS 
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE

I have tried all the following EXPRESSIONs and they all report an error 
int logfile.

EXPRESSION ("[RTTYP]" ~* /U|S|C/)
EXPRESSION ("[RTTYP]" ~* /(U|S|C)/)
EXPRESSION ("[RTTYP]" ~* /^(U|S|C)/)
EXPRESSION ("[RTTYP]" ~* /^[USC]/)

EXPRESSION ("[RTTYP]" ~* "/U|S|C/")
EXPRESSION ("[RTTYP]" ~* "/(U|S|C)/")
EXPRESSION ("[RTTYP]" ~* "/^(U|S|C)/")
EXPRESSION ("[RTTYP]" ~* "/^[USC]/")

EXPRESSION ("[RTTYP]" ~* "U|S|C")
EXPRESSION ("[RTTYP]" ~* "(U|S|C)")
EXPRESSION ("[RTTYP]" ~* "^(U|S|C)")
EXPRESSION ("[RTTYP]" ~* "^[USC]")

So for example:
EXPRESSION ("[RTTYP]" ~* /U|S|C/)
generates:
msEvalExpression: Expression parser error. Failed to parse expression: 
"M" ~* /U|S|C/

EXPRESSION ("[RTTYP]" ~ "/U|S|C/")
msEvalExpression: Expression parser error. Failed to parse expression: 
"M" ~ "/U|S|C/"

EXPRESSION ("[RTTYP]" ~ "U|S|C")
msEvalExpression: Expression parser error. Failed to parse expression: 
"M" ~ "U|S|C"

And /[USC]/ and "/[USC]/" and variants reports:
Failed to draw layer named 'roads'.; msDBFGetItemIndex(): DBASE file 
error. Item 'USC' not found.

The documentation at:
http://mapserver.org/mapfile/expressions.html#regular-expression-comparison

is very ambiguous with some examples of regex like 'by$' without the 
slashes and others with slashes.

So I will write a bug on the doc, but I would like to include the 
correct syntax and since I can not find anything that works :(

I'm probably missing something stupid, but if not this seems like a 
serious issue.

-Steve W


More information about the mapserver-dev mailing list