Solved

XSLT - String ending with a numeric

Posted on 2011-09-13
5
263 Views
Last Modified: 2012-06-21
How do i test if a String ends with a numeric ?
0
Comment
Question by:Molko
  • 4
5 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36532206
given the string is $str

<xsl:if test="translate(substring($str, string-length($str)), '0123456789', '') = '' " >
...
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36532214
substring takes the last character
the translate maps any digit to nothing
if the last character is a digit, this translate returns a ''
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 36532223
in XSLT2

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

Author Comment

by:Molko
ID: 36532421
Hi

yeah, think i prefer the regex
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 36532645
me too, but for that you need an XSLT2 processor
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scraping specific data within an XML document 19 57
How to read XML file attributes... 17 63
AL3 Files 4 29
XSLT Display Label Name 1 22
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question