From: Stefan M. <ste...@un...> - 2010-10-05 21:06:24
|
Quite a while ago I wrote the message below. At that time I noticed that XQuery does not allow for look-aheads and look-behinds in regexes. Nonetheless, exist at that time used java regex syntax which allowed that. Obviously that has changed, as I get this error when migrating some patterns from 1.4 to current trunk. a call to matches() with an offending regex yields the following message: |Conversion from XPath2 to Java regular expression syntax failed: Error at character 2 in regular|| expression (\b)(test)(\b): invalid escape sequenc| This is just a stupid example, I know, but at some points lookahead/behind can be very handy. I am just wondering if there is any chance to get java regex behaviour back? I fear it is for some reason not possible, like standards conformance, indexes?. I guess I could find some kind of work-around. Anybody else stumbling over things like this? cheers, Stefan On 19/02/09 14:47, Stefan Majewski wrote: > I recently ran into the limitations of regexes in XSLT as according to > the official specifications there is no lookahead or similar mechanisms > allowed. This is very different to what would be allowed in Java's regex > engine, where constructs like \b (?= (?<= and the like are possible. > Saxon does, even though it is implemented in Java, adhere very strictly > to the standards and does consequently not allow these constructs. > > eXist nevertheless, does, even though this is not standard, allow for > these extensions. I can't see a problem in this, as the regex engine > still accepts everything that would be allowed by the XQuery/XPath specs > for match(), tokenize() and replace(). > > Nevertheless, now that I have moved portions of the logic outside of the > XSL transformation, I wonder whether eXist's behaviour is intended to > stay as it is or follow the saxon approach at one point and forbid > lookahead patterns? > > It would be nice if anyone could comment on this, as if it weren't the > case I would have to watch out and move it one day as a user-defined > functioninto my private module. > > best, > > Stefan > > -- | Stefan Majewski | Department of English, University of Vienna | | VOICE Corpus | Spitalgasse 2-4, Universitätscampus AAKH, Hof 8 | | | A-1090 Vienna | | Research Ass.(IT)| Phone: +43 1 4277 424 46 | |