From: [EMAIL PROTECTED]
Date: Wed, 7 Jun 2006 08:46:58 -0600

They have
either a CR or LF for a fifth character in its name. There are
others. Is there a RegEx or encoding way to strip out all hidden
characters in a string? Or, is there another way - other than the
obvious way of walking the string and examining each character. I
guess what I'm trying to say is there an elegant way of doing this?

If you know they'll be at the beginning or end of the name, then a simple Trim() should do it. If not, then you might use s = StringUtils.Remove(s, StringUtils.ControlCharacters). This is part of the free String Utilities module at <http://www.verex.com/ opensource/>.

It could be done with RegEx too, but it'd be more work and probably less efficient.

dim cs as ElfDataCharSet
cs = StringUtils.ControlCharacters // or some other function that returns a string containing them
s = cs.Strip( s )

this will be faster than string utils, assuming you cache the ElfDataCharSet object and don't recreate it everytime.

ElfDataCharSet internally uses a 256 byte array of booleans, so it's pretty hard to beat in speed, because of it's implementation's brute force simplicity :)
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to