LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing non-alpha-numeric characters from a string

How can I remove all non-alpha-numeric characters from a string? (i.e. only alpha-numerics should remain in the string).
Message 1 of 25
(22,195 Views)
Like this?
 

___________________
Try to take over the world!
Message 2 of 25
(22,193 Views)
Or even without a loop ?




Extract from the help for the Search and Replace String function :
Right-click the Search and Replace String function and select Regular Expression from the shortcut menu to configure the function for advanced regular expression searches and partial match substitution in the replacement string.

Extract from the for the advanced search options :
[a-zA-Z0-9] matches any lowercase or uppercase letter or any digit. You also can use a character class to match any character not in a given set by adding a caret (^) to the beginning of the class. For example [^a-zA-Z0-9] matches any character that is not a lowercase or uppercase letter and also not a digit.



Message Edité par JB le 05-06-2008 01:49 PM
Message 3 of 25
(22,180 Views)
Yep, that looks better. I happily never had the need to use regexes too much, so the less I know about them the better. Smiley Wink

___________________
Try to take over the world!
Message 4 of 25
(22,162 Views)
I'm ever again astonished by these string format specifiers ! So compact and powerful ! So easy... once the code works ! And at the same time so incomprehensible unless you are very familiar with them !

Get File Extension.vi (Functions palette >> File I/O >> Advanced File Functions) with its \.[~\.]*$ format specifier is a good example.




Message 5 of 25
(22,158 Views)
Yes, but I was always one of those who go with the feeling that languages like Perl look like an explosion in an ASCII factory. Having to decipher those hiroglyphics is not that much fun.

___________________
Try to take over the world!
Message 6 of 25
(22,148 Views)
You folks should try to spend some time with bash scripts and grep. Your heads will start spinning, as mine has on multiple occasions. Smiley Very Happy
0 Kudos
Message 7 of 25
(22,128 Views)
I would recommend to recruit the "lexical class" tool from the comparison palette for this, it can simplify your code quite a bit.
 
You want lexical classes 3,4, and 5.
 
Check the online help.
Message 8 of 25
(22,122 Views)

Does that mean that once you have the Lexical class/classes you can filter strings with them?

Craig

LabVIEW 2012
0 Kudos
Message 9 of 25
(22,118 Views)
Here's a quick draft that would do the current problem.
 


Message Edited by altenbach on 05-06-2008 08:34 AM
Message 10 of 25
(22,113 Views)