Jump to content

stripping chars from a string


Domitan Redenblack
 Share

You are about to reply to a thread that has been inactive for 4699 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 4699 days.

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...