LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

regular expression for finding anything which isn't a defined sequence

Solved!
Go to solution

Hi there,

 

Just having a little trouble with a regular expression. I have an input string and I want to find anything that isn't that string, so

 

Input = Hello

Match = Hello

Match? = False

 

Input = Hello1

Match = Hello

Match? = False

 

Input = Hello

Match = Goodbye

Match? = True

 

As I thought I understood it, to enter it as a regular epression in the Match Regular Expression.vi would be ~(Hello).

As I also understand it, I can't achieve this by using match pattern.

 

Perhaps you good folks can correct me. Thanks!

0 Kudos
Message 1 of 14
(3,937 Views)

do you mean this 

0 Kudos
Message 2 of 14
(3,910 Views)

Yes that's functionally the same although I'm trying to work with an existing API and so was looking for a single regular expression that would do the same ideally so I don't have to change the interface to include the case.

0 Kudos
Message 3 of 14
(3,897 Views)

so does your problem solve with that vi or you need some thing more ?

0 Kudos
Message 4 of 14
(3,892 Views)

@rik_aspinall wrote:

Hi there,

 

Just having a little trouble with a regular expression. I have an input string and I want to find anything that isn't that string, so

 

Input = Hello

Match = Hello

Match? = False

 

Input = Hello1

Match = Hello

Match? = False

 

Input = Hello

Match = Goodbye

Match? = True

 

As I thought I understood it, to enter it as a regular epression in the Match Regular Expression.vi would be ~(Hello).

As I also understand it, I can't achieve this by using match pattern.

 

Perhaps you good folks can correct me. Thanks!


If I understand you want Match? to be true if the input string doesn't contain Hello?

 

Match.png

 

Ben64

0 Kudos
Message 5 of 14
(3,888 Views)

Folks, perhaps I should add more info - I'm trying to achieve this only by entering somethining into the regular expression field, and not by adding code. Thanks, Rik

0 Kudos
Message 6 of 14
(3,864 Views)

@rik_aspinall wrote:

Folks, perhaps I should add more info - I'm trying to achieve this only by entering somethining into the regular expression field, and not by adding code. Thanks, Rik


It would then be very helpfull to see what the actual code looks like. How is the Match? value generated? You're talking about defined sequence, can you show us what typical sequence looks like? And what are the expected values returned from each output of the Matched Pattern vi?

 

Ben64

0 Kudos
Message 7 of 14
(3,856 Views)

It's pretty much like the snippet you posted, except that

1) to detect a match I check if the count returned is equal to -1 rather than use the match string being empty.

2) The actual text I'm searching for is a vi name that is printed in an error log, so as I described above if I were searching for "~(Hello.vi)" as a match, "Hello.vi" would return a false while "SayHello.vi" would return a true or even "PrintHello.vi.vi" would return a true. That is, I'm looking for anything that isn't exactly the name of the .vi string. Perhaps we could think of it like stripping any records containing "Hello.vi" from out of the log because they are trivial.

0 Kudos
Message 8 of 14
(3,838 Views)

this vi help you to find vi in error comment 

0 Kudos
Message 9 of 14
(3,826 Views)

Rik,

 

If my understanding of your requirement of the test is correct, are you just looking to see if the two strings are different?

 

If so, why don't you just use not_equals?

 

It doesn't have to have numeric inputs.

See http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/comparison_funcs

http://zone.ni.com/reference/en-XX/help/371361J-01/lvhowto/string_comparison/

 

Rod

0 Kudos
Message 10 of 14
(3,813 Views)