String Operations

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?

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)
1 Like

Thanks. Worked like a charm.