String replace

This is probably very simple but I have a variable bound to a string value and I want to remove a specific character (always the first character, always an “S”) from the string. :o

There are any number of different ways to approach this one.

Probably the simplest is to use regular expressions:

$b = $a.replaceFirst("^S","")

See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html and
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#sum

It’s also possible to build a JEXL scriptlet:

if($a.startsWith("S")) {$a.substring(1);} else { $a; } 

I’m sure that some of our more imaginative readers could come up with a few more ways.

Maybe we should have a contest.

Dave