01-11-2016 01:19 PM
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!
Solved! Go to Solution.
01-11-2016 02:30 PM
do you mean this
01-11-2016 03:04 PM
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.
01-11-2016 03:09 PM
so does your problem solve with that vi or you need some thing more ?
01-11-2016 03:09 PM
@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?
Ben64
01-11-2016 03:56 PM
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
01-11-2016 04:06 PM
@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
01-11-2016 04:34 PM
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.
01-11-2016 04:49 PM
this vi help you to find vi in error comment
01-11-2016 05:06 PM
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