Project

Profile

Help

Regex problem?

Added by Anonymous about 17 years ago

Legacy ID: #4546154 Legacy Poster: Martin Roberts (robertmm)

Hi, Firstly I find regex one of the most difficult software concepts to get my head round so this may be a problem with me! I have a string "one|two|three" and I want [one][two][three] (don't ask why!) I started by using regexbuddy to get the regex that would match the words of the string and '(\w+)' seemed to give me one two and three. In saxon replace the the expression replace('one|two|three','(\w+)','[$1]') - if regexbuddy is right I should get the expression I want but I get [as|qw|er]. Am I going mad!!! Martin


Replies (1)

RE: Regex problem? - Added by Anonymous about 17 years ago

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

Could I suggest that you ask for coding help on either the xsl-list at mulberrytech.com, or the xquery list at (depending whether you're in XSLT or XQuery), since there's nothing Saxon-specific about this question. I don't know where you get [as|qw|er] from. I get [one|two|three]. The exact meaning of some escape sequences like \w varies from one regex dialect to another. In XPath and XML Schema the definition is: any character that isn't in Unicode groups P or Z or C. For better or worse, vertical bar is in group S (it's classed as a mathematical symbol) and therefore matches \w, as do characters like "+" and "=".

    (1-1/1)

    Please register to reply