Best LotusScript way to strip out all instances of a character from a string?

If I have a social security number that is for instance 000-00-0000, how do I with Lotusscript remove out all the “-” characters with the result being 000000000 ?

Thanks!

Subject: Best way to strip out all instances of a character from a string?

In Formula Language, @ReplaceSubstring; in LotusScript, Replace; in JavaScript, replace(); in Java (currently supported JVMs), you’ve got to do it the hard way.

Subject: RE: Best way to strip out all instances of a character from a string?

Alternative Formula:@Implode(@Explode(“000-00-0000”;“-”);“”);

cheers,

Bram

(who thinks that the ability to create/parse funky @formulae is one of the better ways to recognize a good notes programmer :wink:

Subject: RE: Best way to strip out all instances of a character from a string?

Forget I wrote anything here. It was wrong. :slight_smile:

Subject: Replace operates on an array of strings

Not correct. Replace can operate on a list (array) of strings just like @ReplaceSubstring.

Subject: RE: Replace operates on an array of strings

Sorry I clarified what I meant. Replace does not allow you to work with a single string value and replace contents within that string. It is replacing array indexes. Or, to be more clear (hopefully), Replace is a LS equvalent to @Replace not @ReplaceSubstring. The latter has no LS equiv that I know of outside of the workaround I posted.

Subject: RE: Replace operates on an array of strings

Sure it does:

Sub Click(Source As Button)

Messagebox Replace(“Once is never enough”,“Once”,“Twice”)

End Sub

Subject: RE: Replace operates on an array of strings

Oh SOB. I swear I’d read that doc hoping it would allow that and I saw “If sourceArray, replaceArray, or replacementArray is not either a String, or an Array of type String, then a run-time type mismatch error is thrown.” as “If sourceArray, replaceArray, or replacementArray is not an Array of type String, then a run-time type mismatch error is thrown.”

So many times I could have used that but kludged around it… sigh Thanks!

Subject: RE: Replace operates on an array of strings

Haha, I got it - Replace() worked. Thanks mates.