Link to home
Start Free TrialLog in
Avatar of Steven O'Neill
Steven O'NeillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Get last 10 digits of an xsl value-of field

I have, what is hopefully, an easy question but my heads just not working at present.

I have an XSL file and within that I have a field where I'm trying to take the last 10 digits from. The code I current have is this:

<xsl:value-of select="substring($this-initial/CODE,4)"/>

Open in new window


I know this snippet is starting from character 4 but what I'm trying to do is take the field that may have 10 but may have 14, 16 or more characters and simply take the last 10 of them and use this as the value.

Any advice appreciated.
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
it does make sense to make a variable that takes $this-initial/CODE so you need to calculate that only once
It also make sense to put the stringlength in a variable first to check the CODE has more than ten characters to begin with, b

But the above should get you started
note that your question is a little bit dubious
you start about digits and then you go on about characters
I did assume that the string is just all digits,
if not and you really need digits, the solution is not harder but different
Avatar of Steven O'Neill

ASKER

Hi Geert

Thanx for the responses and apologies for the question wandering somewhat. I was being rushed out the door and was trying to simply get my thoughts down and the questions asked. Here's a better explanation (hopefully).

The field in question is coming from an XLSX file and it can contain data like:

ABC1234567890
ABCDE1234567890
1234567890

Basically it will always have 10 numerical digits at the end of the string so I only need to pull this out from the field and ignore everything else.

I think your original code above will do this but hopefully this explanation gives you a better idea what I'm trying to accomplish and you'll be able to determine if the code is correct...seems to work from what I've seen though.

Thanx again

Steven
Hi Steven,

No apologies needed.
Thanks for further explaining.
From what you describe, I understand that the code should do what you need

Cheers

Geert
Speedy response as always from Geert, thanx again