LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing non-alpha-numeric characters from a string

Ahh Quite handy to know, Thanks
LabVIEW 2012
0 Kudos
Message 11 of 25
(4,247 Views)

altenbach wrote:
I would recommend to recruit the "lexical class" tool from the comparison palette for this, it can simplify your code quite a bit.

I thought about the lexical class primitive originally, but discarded the idea because it works on a single character.
 
I never thought I would live to see the day where Altenbach suggests a loop (with a resizing operation, no less) as the simpler solution to a single primitive. Smiley Very Happy

___________________
Try to take over the world!
Message 12 of 25
(4,226 Views)


tst wrote:

I never thought I would live to see the day where Altenbach suggests a loop (with a resizing operation, no less) as the simpler solution to a single primitive. Smiley Very Happy


Hey!!! 😄
 
Yes, the loop can be done essentially in-place by re-using the input array with a little bit more code. Yes, the primitive is probably a more natural choice, but it requires fancy knowledge to compose the pattern string. 😉
 
The purpose of my post was more educational to draw attention to the "lexical class" primitive. Most people have never seen it. 🙂 It can be useful.
 
Performance wise, the "search and replace all" is a multipurpose VI and the parsing and matching is probably more expensive than the lexical class, which could be implemented as a simple 8bit lookup table. I have not done any benchmarks though. 🙂
Message 13 of 25
(4,218 Views)
That's the same exact impression I had when I saw the example!

Maybe he really, really dislikes regex expressions. Smiley Very Happy

EDIT: Darn! Posted it right after altenbach's response (must have been within the same second given the timestamps). Oh well.


Message Edited by smercurio_fc on 05-06-2008 12:40 PM
Message 14 of 25
(4,214 Views)


smercurio_fc wrote:
Maybe he really, really dislikes regex expressions. Smiley Very Happy

I think you are on to something here!
 
It is true that I use these things rarely enought that I always need to consult the help screen. As soon as I need anything fancier, I never get things right on the first try. One reason I like LabVIEW is the fact that it is graphical and does not require any verbal syntax constructs. Any regex throws me back to the old text based code in some way. 😄
Message 15 of 25
(4,180 Views)
Smiley Very Happy Smiley Very Happy That's exactly the same way I react whenever I have to use those regex expressions. I invariably have to crack open the full LabVIEW Help file to get those right.
Message 16 of 25
(4,177 Views)
Thanks a lot for the answer.

One more query! How do you show the code pic on your post? (Do you upload your pics to some other image hoster and link to your post from there? If yes which image hoster do you recommend?)
Message 17 of 25
(4,165 Views)
Yup this worked for me! Thanks a lot, friend!
Message 18 of 25
(4,165 Views)
Dear altenbach! I'm left in the dark by your reply! What is lexical class? Do I need to install something to have access to it? What does it do?
Message 19 of 25
(4,162 Views)

@rashid19672008 wrote:
Thanks a lot for the answer.

One more query! How do you show the code pic on your post? (Do you upload your pics to some other image hoster and link to your post from there? If yes which image hoster do you recommend?)


I use Code Capture Tool. To place an image into your post, attach the file to your post. Submit the post, and then go back to edit the post. Right-click on the URL for the attachment and select "copy url" (or something like that). Then, place the cursor where you want the picture, click the picture icon in the toolbar above the message entry area and paste in the URL.


Message Edited by Support on 05-07-2008 02:26 PM
Message 20 of 25
(4,162 Views)