取消
顯示結果 
搜尋替代 
您的意思是: 

TestStand RegEx evaluation fails.

Hi! 

When using regular expression in teststand it fails. I am trying to get Stats : READY from the string using regular expression as (Status)\s:\s(READY). Although in the attachment I just tried to get READY and that too is not passing. 

Any suggestions on what is causing this?

Thanks!!

*************************************************
CLD
*************************************************
0 積分
1 條訊息(共 8 條)
2,819 檢視

Does anyone has any suggestions on why this regular expression is not evaluating and teststand returns Failed status?

*************************************************
CLD
*************************************************
0 積分
2 條訊息(共 8 條)
2,783 檢視

I think the problem is that it's not clear what you are asking for.  Is this in a String Value Test step?  Or just an expression in TestStand.

 

What do you mean by "not passing"?  It's not doing what you want or the sequence context status is being set to Failed?

 

Maybe you could give us some more context?   Like specifically what are you expecting back from your code module and what is considered passing vs failing?

 

Thanks,

 

 

jigg
CTA, CLA
testeract.com
~Will work for kudos and/or BBQ~
0 積分
3 條訊息(共 8 條)
2,777 檢視

It is a string value type.
I am trying to use regular expression to validate a part of the string that is returned in Step.Result.String from the code module.
So the String is 

IMEI : 00009999222 Status : READY

 

The regular expression that I have is (Status\s:\sREADY)

 

I notice when I set the UseCompExpr to False, the Step.Status is Failed (previous image)
If I set UseCompExpr to True, it returns Invalid for Comp field (image attached)

All I am trying to achive is to pick the Status\s:\sREADY from Step.Result.String.

Thanks!!

*************************************************
CLD
*************************************************
0 積分
4 條訊息(共 8 條)
2,767 檢視

Any suggestion as to what is incorrect in performing the regEx?

Thanks

*************************************************
CLD
*************************************************
0 積分
5 條訊息(共 8 條)
2,751 檢視

I got it to work as follows.  It seems the Regular Expression has to match everything in the input string.  I know with Match Pattern in LabVIEW you can specify part of the string (as you had done) and it will work.

 

 

Teds_1-1658934306848.png

 

PH

6 條訊息(共 8 條)
2,746 檢視

Thank you so much, that works although it is interesting that teststand can't return groups.

*************************************************
CLD
*************************************************
0 積分
7 條訊息(共 8 條)
2,737 檢視

The FindPattern function in TestStand behaves like you'd expect it would:

 

Locals.InputString = "This is a stupid test string"
,Locals.MatchOffset = FindPattern( Locals.InputString, "stupid", 0, True, Locals.MatchLength )
,Locals.OutputString =  Mid( Locals.InputString, Locals.MatchOffset, Locals.MatchLength )
,Locals.FoundMatch = Locals.MatchOffset > -1

 

After that executes, Locals.OutputString is "stupid", Locals.MatchOffset is 10, and Locals.MatchLength is 6.

 

I am fairly fluent in PCRE and I write regexes, some very complex, regularly, but I was tearing my hair out trying to figure out why I couldn't get the MatchPattern function working with the most basic test. I was about to conclude that it's a completely broken feature until I ran across this thread.

 

@Teds is correct about the MatchPattern function. You have to write your regex to match the entire string, not just a portion of it:

 

Locals.InputString = "This is a stupid test string"
,Locals.FoundMatch = MatchPattern( Locals.InputString, ".*(stupid).*", True, Locals.SubMatches )
,Locals.OutputString = GetNumElements( Locals.SubMatches ) >= 2 ? Locals.SubMatches[ 1 ] : ""

 

You can't just put in something like "\s(stupid)\s", because it only matches a portion of the string.

To me, this is counterintuitive and bizarre, but maybe the NI software engineer that implemented this function was used to a similar implementation in another language.

 

@lvrat, TestStand can indeed return submatches. It's just weird about it.

 

Locals.InputString = "I shoved my laptop onto the floor, yelled at the wall, and slammed the door on the way out"
,Locals.FoundMatch = MatchPattern( Locals.InputString, ".*?(laptop).*?(floor).*?(door).+", True, Locals.SubMatches )

 

After this executes, Locals.SubMatches = { "I shoved my laptop...", "laptop", "floor", "door" }

 

For anyone else who reads this later, if you're not too familiar with submatches, with a lot of implementations in various languages it's pretty common for element 0 in the SubMatches array to be the full match, followed by the actual submatches.

 

The TestStand documentation (at the time of writing this) is not at all clear about this quirk with MatchPattern.

https://www.ni.com/docs/en-US/bundle/teststand-api-reference/page/tsfundamentals/matchpattern-functi...

 

Have fun.

Mr. Jim

 

8 條訊息(共 8 條)
1,018 檢視