LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

alphanumeric string

How to check for an alphanumeric string using Regexp function?

0 Kudos
Message 1 of 20
(5,132 Views)

[^\d\w]

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 20
(5,127 Views)

Thanks a lot. But the above VI fails if i give underscore or empty space so we should add condition for it i guess.

I also got it in a similar way . I am trying without using regexp , by using ASCII . Is there any way of achieving it , suppose i give a single character and it should check for alphanum.

I have also enclosed in my VI for conversion and checking for alphanum string.

0 Kudos
Message 3 of 20
(5,118 Views)

Why do you want to avoid using regular expressions?  Unless you're using this in a loop that needs to go very fast, a regexp is fine (and much cooler).

 

Sorry about forgetting the underscore; how's this?  The "pipe" is an OR operator.  This regexp looks for anything that's not a word character (letters, digits and underscores) and then looks for an underscore.  If it finds either, the input string is not alphanumeric.

 

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 4 of 20
(5,107 Views)

I agree with Jim about the coolness of regex.

 

NOTE: The pipe and underscope should be included in the character class, the correct regex is [^\w|_]

 

Ben64

0 Kudos
Message 5 of 20
(5,090 Views)

@ben64 wrote:

[...]

 

NOTE: The pipe and underscope should be included in the character class, the correct regex is [^\w|_]


 

That won't work.  My regexp is looking for anything that's not a word character or IS an underscore.  Yours looks for anything that's not a word character or an underscore, which is redundant and misses the underscore.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 20
(5,085 Views)

Sorry about that, I guess I misunderstood what is asked. I thought the OP was looking for anything that's not ( a word character or an underscore ).

 

Ben64

0 Kudos
Message 7 of 20
(5,082 Views)
Remember that you can capitalize a character class for negation.
0 Kudos
Message 8 of 20
(5,069 Views)

"Any technology sofisticated enough is indistinguishable from magic."

Regexp is magic.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 20
(5,049 Views)

of course there is the Lexical class function on the comparision palatte to do all the regexs for you!

 

Hmmmmm This round thing is neat--- I should call it a "Wheel"


"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 20
(5,042 Views)