strMatches fails with multi-line string

Bug #612596 reported by James Shepherd
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
TestPlan
Invalid
Undecided
Unassigned

Bug Description

I would expect the following .test to output "Notice: et even more"

set %Text% <<EOF
Line: Value
More: And More
Yet even more
EOF

if strMatches %Text% Y(.*)
 Notice %Return:Group:1%
else
 Notice FAIL
end

But it outputs "Notice: FAIL"

It looks like strMatches doesn't work with multi-line strings.

Revision history for this message
edA-qa (eda-qa) wrote :

strMatches is a complete string match, even in the multi-line case. Thus your check for matching should be expected to fail.

You can however use the "strContains" function which should do what you want. Though you may want to also match beginning of line/end-of-line:

if strContains %Text% ^Y(.*)$
 Notice %Return:Group:0%
else
 Notice FAIL
end

Be aware that <<EOF preserves leading space on the lines, so Y must be the first character here. Also, I've output group 0 instead of 1, since group 1 is the string "et even more".

Changed in testplan:
status: New → Invalid
Revision history for this message
James Shepherd (j-shepherd) wrote :

Oh I see. The java meaning of match, rather than the perl or php one :-)

Revision history for this message
edA-qa (eda-qa) wrote :

Well, in Java by default I think it'd also do the match you want. In TestPlan though, for convenience since you deal with a lot of multi-line input, the moment multiline input is detected it switchs to multiline mode. I think both PHP and PERL have such a matching mode.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.