Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

XSLT - String ending with a numeric

Posted on 2011-09-13
5
271 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to read XML file attributes... 17 71
Cordova Camera plugin fails 2 140
Wordpress Hacked 1 26
How does proportional-column-width work in xsl fo 4 9
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

861 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