Remove from a String

Discussions about the LSPS expression language.
Forum rules
Make sure every topic contains information about your LSPS version and if relevant also your server OS, client OS, database name and version, and application server name and version.
eric.graham
 
Posts: 58
Joined: Tue May 13, 2014 12:20 pm

Remove from a String

Mon Jun 01, 2015 3:00 pm

Hello - I have an issue where I have a String type, and I need to remove the last 3 characters from it. (this does need to be and stay type String...or at least be converted back into a String).
I know Java has String manipulation...but I am not sure how to handle this is LSPS expression language.
Example of what I need:
The String "number" has a value of 1234567001 (that gets the value from a database),
I need to remove the last 3 characters of "001" so that it is 1234567.
Not sure how to approach this in the EL, could you please advise?

Thank you in advance!

djeison.selzlein
 
Posts: 34
Joined: Fri Feb 27, 2015 4:38 pm

Re: Remove from a String

Mon Jun 01, 2015 3:12 pm

Hello,

You may use the Standard Library's function substring(string, fromIndex, toIndex);
For your situation the usage would be something like this:

substring(number, 0, length(number)-3);

This is suppose to return "1234567" if number variable has value of "1234567001".
I hope it helps.

eric.graham
 
Posts: 58
Joined: Tue May 13, 2014 12:20 pm

Re: Remove from a String

Mon Jun 01, 2015 3:31 pm

Very straight forward...thanks for your timely response djeison, I really appreciate it!

djeison.selzlein
 
Posts: 34
Joined: Fri Feb 27, 2015 4:38 pm

Re: Remove from a String

Mon Jun 01, 2015 3:33 pm

No problem Eric. I am glad it worked.

Return to Expression language

Who is online

Users browsing this forum: No registered users and 1 guest