XSLT - String ending with a numeric

How do i test if a String ends with a numeric ?
MolkoAsked:
Who is Participating?
 
Geert BormansConnect With a Mentor Information ArchitectCommented:
me too, but for that you need an XSLT2 processor
0
 
Geert BormansInformation ArchitectCommented:
given the string is $str

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

<xsl:if test="matches($str, '\d$')" >
...
0
 
MolkoAuthor Commented:
Hi

yeah, think i prefer the regex
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.