[xsl] regular expressions in XSLT 2.0

Subject: [xsl] regular expressions in XSLT 2.0
From: Wolfhart Totschnig <wolfhart@xxxxxxxxxxxxx>
Date: Sun, 28 Aug 2011 16:12:36 -0500
Hello,

I have a question about regular expressions in XSLT 2.0. I noticed that

test="matches('40e','^\d{1,3}|[ivxl]{1,7}$')"

will be evaluated as true, which puzzles me, since I thought it should be evaluated as false. (A regular expressions test page I found on the internet (http://www.fileformat.info/tool/regex.htm) indeed evaluates the test as false.)

When I add parentheses in the regular expression, i.e.,

test="matches('40e','^(\d{1,3}|[ivxl]{1,7})$')"

the test comes out false, however.

So my question is this: Why does the test without the parentheses come out true? That is, how is the regular expression interpreted by the xslt engine such that "40e" is considered a match? And why to the parentheses make a difference? (I thought the parentheses would be redundant in this case.) Or is this maybe an issue specific to the xslt engine I use (Saxon9he)?

Thanks in advance for your help!
Wolfhart

Current Thread