Forum Discussion

M_McDonald's avatar
M_McDonald
Super Contributor
15 years ago

Matching beginning of line in multiline text in Contains assertion

Hi -

I have some multiline text in a response like this:

[tt:1jswjg8j]---------------------------------------------
Other Name                : Jane Smith
Name                      : John Doe
Current Address           : 123 Main St
---------------------------------------------[/tt:1jswjg8j]


In a Contains assertion I want to test for the "Name" line in this text and NOT match "Other Name". If I use

[tt:1jswjg8j](?s).*Name\s*: J.*[/tt:1jswjg8j]

both name lines can be matched, but when I try this:

[tt:1jswjg8j](?s)^Name\s*: J.*[/tt:1jswjg8j]

neither is matched. What am I missing?

Thanks.

Futher update - using Groovy Console, I was able to to use

[tt:1jswjg8j](?m)^Name\s*: J.*?$[/tt:1jswjg8j]

to match the line I wanted, but this does not seem to work in the Contains assertion in SoapUI.