Jump to content

stripping chars from a string


Domitan Redenblack
 Share

You are about to reply to a thread that has been inactive for 4131 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

What do you think is the best way to "alpha-numericize" a string?

That is, strip all chars except <space>, A_Z, a-z, and 0-9

Or, more generally, have a string of allowable chars 'sKeepChars' ?

Use a loop through the string and lookup each char of it in the sKeepChars?

Any more clever ways for LSL to do it?

 

ty

 

Link to comment
Share on other sites

I use a validation technique in my calculator that may be helpful. it doesn't actually strip characters, but it does provide the potential to do so be eliminating all valid characters in a temp string leaving only invalid ones..

I take a sting, make a temp copy.
the temp copy is parsed to list, removing 8 valid characters as discarded separators, then the list is cast back to string
the process is repeated for each 8 characters to remove, until all valid characters are removed.
if anything is left, it's an invalid character or characters, and could be used to eliminate them from the original string...

the relevant part can be found at the beginning of this script (first four lines after variable declaration)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4131 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...