Link to home
Start Free TrialLog in
Avatar of Molko
Molko

asked on

XSLT - String ending with a numeric

How do i test if a String ends with a numeric ?
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

given the string is $str

<xsl:if test="translate(substring($str, string-length($str)), '0123456789', '') = '' " >
...
substring takes the last character
the translate maps any digit to nothing
if the last character is a digit, this translate returns a ''
in XSLT2

<xsl:if test="matches($str, '\d$')" >
...
Avatar of Molko
Molko

ASKER

Hi

yeah, think i prefer the regex
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial