Project

Profile

Help

analyze-string failing?

Added by Anonymous over 16 years ago

Legacy ID: #4758990 Legacy Poster: David Pérez (david-perez)

I have tried in the latest version of Saxon (9.0.3) this simple sample: <xs:analyze-string select="' This vacancy was placed by Pepitou'" regex="'This +vacancy +was +placed +by +(.+)'" flags="i"> <xs:non-matching-substring>{<xs:value-of select="."/>}</xs:non-matching-substring> <xs:matching-substring>[<xs:value-of select="regex-group(1)"/>]</xs:matching-substring> </xs:analyze-string> I expect to have this output: [Pepitou] instead of { This vacancy was placed by Pepitou} Is this a bug? Is there a workaround to extract a part from a string? Thanks in advance for any help.


Replies (2)

RE: analyze-string failing? - Added by Anonymous over 16 years ago

Legacy ID: #4759142 Legacy Poster: Michael Kay (mhkay)

The regex attribute is an attribute value template, not an XPath expression, so the inner apostrophe delimiters are incorrect. They are taken as part of the regex, which causes it to not match the input string. Michael Kay

RE: analyze-string failing? - Added by Anonymous over 16 years ago

Legacy ID: #4760009 Legacy Poster: David Pérez (david-perez)

Thanks a lot. The answer is so surprisingly simple, that I don't understand how I couldn't be able to see it.

    (1-2/2)

    Please register to reply