Subject: [xsl] Using XSL variable in XQuery regular expression|
Date: Thu, 16 Dec 2010 13:30:41 -0500
Dear List, Is it possible to use an XSL variable in a regular expression when using the "matches" function in an XSL transformation? Say I have <xsl:variable name="Prefix" as="xs:string" select="'PR'"/> Then I want to use $Prefix in my regular expression like I might use XSL variables elsewhere: matches(normalize-space(text()), '^(optional beginning text)*$Prefix: [a-zA-Z ]*') $ is a special character in regular expressions. I haven't found examples of variables in regular expressions in my internet searching. I'd like to match text that starts with 'PR', such as "PR1234: Some problem to report". I'd also like to match text that may have some other initial characters, then the 'PR' prefix and more text, such as "optional beginning text PR9876: Another problem". I could put the literal 'PR' in the regular expression, but I was hoping to factor that out for use in a few other regular expressions, and have only one place to edit if the prefix string changed. Thanks for suggestions, or letting me know this can't be done. Sincerely, Mike Cook This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original.