LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression to exclude spaces in string

Solved!
Go to solution

Now that I'm cross-eyed, I need help with a regular expression.

 

These need to pass (or permutations thereof):

 

[00123]

[R012]

[r083]

 

 

These need to fail (or permutations thereof):

[test]

[I was here]

[098 876]

[29873 eifvuh]ouh]

 

I have most of it ( the '[' has to be first; the ']' has to be last; there have to be numbers in the middle, but I can't write an expression that fails if there is 1 or more spaces in the string.

 

Thanks!

 

Tay

0 Kudos
Message 1 of 7
(11,989 Views)
DO you need it to fail only on sapces? If so then the first one in the fial group would pass [test]
Tim
GHSP
0 Kudos
Message 2 of 7
(11,984 Views)

It needs to fail if there are 1 or more spaces, and if there are no numbers, and actually if there is more than one letter, so [test] needs to fail.

 

Tay

Message Edited by slipstick on 11-20-2009 11:54 AM
0 Kudos
Message 3 of 7
(11,980 Views)
Solution
Accepted by topic author slipstick

Several possibilities:  Try this regular expression.

 

^\[[a-zA-Z]*[0-9]+[a-zA-Z0-9]*\]$

 

Message 4 of 7
(11,962 Views)
Here is what I would do.
Tim
GHSP
Message 5 of 7
(11,959 Views)
Darin.K's version is easier
Tim
GHSP
0 Kudos
Message 6 of 7
(11,953 Views)
The filter string is an approach I hadn't thought of. I'll keep it in mind for the future. Both great solutions! Thanks! Tay
0 Kudos
Message 7 of 7
(11,942 Views)