String Operations


(Courtney James) #1

I know that you can use the plus sign operator to concatenate strings. Is there an operation that I can use to strip off the last N characters of a string?


(Galen Menzel) #2

Here are a couple ways. Replace N with the value you want.

Using substr:

$NewString=$OldString.substr(0,$OldString.size-N)

Using a regular expression:

$NewString=$OldString.replace("(.*).{N}",$1)

(Courtney James) #3

Thanks. Worked like a charm.