Re: [xsl] Is there a way in XSLT/XPath to find the portion of a string that matches a pattern?

Subject: Re: [xsl] Is there a way in XSLT/XPath to find the portion of a string that matches a pattern?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Mar 2025 22:04:02 -0000
On 10/03/2025 23:01, Roger L Costello costello@xxxxxxxxx wrote:
Hi Folks,

The following XPath determines if the string in $TEXT contains a vowel:

matches($TEXT, 'A|E|I|O|U')

If there is a match-the string in $TEXT contains a vowel-then which vowel
was matched? A? E? I? O? or U? It may be desirable to know that.

Another example: an XSLT program wants to know the series of digits in a
string; if the string is, "The person put 12 dollars into the jar" and the
pattern is [0-9]+ then the matched portion is "12".

Problem Statement: if the value of $TEXT is a string and the value of $REGEX
is a pattern, then is there a way in XSLT/XPath to find the portion of the
string that matches the pattern?


You do know XSLT 2's and later xsl:analyze-string and XPath 3.1 fn:analyze-string?

Current Thread