Reputation: 2332
**************************
* Ending Case(test) *
**************************
SET: Global["test_status"]=FAILED
=========================
= Ending Test (test) =
=========================
Regex which will return the status i.e. FAILED or PASSED from the above text.
Currently I'm using
.*SET: Global\\W"test_status"\\W=(.*)
But it returns
FAILED
=========================
= Ending Test (test) =
=========================
Thanks in advance
Upvotes: 0
Views: 262
Reputation: 7963
You could use:
"(?m)=(\\w+)\\b"
as the argument to Pattern.compile()
You don't need much context in this example. The pattern is just the multi-line flag (?m) followed by an '=' character as context and a capturing group (\\w+) delimited by a word boundary marker \\b
Use the find() method on the Matcher and extract group 1.
Upvotes: 0
Reputation: 169018
Try this one:
^SET: Global\["test_status"\]=(.*)$
Represented as a Java string:
"^SET: Global\\[\"test_status\"\\]=(.*)$"
EDIT: This pattern should be used with Pattern.MULTILINE
, but not Pattern.DOTALL
.
Upvotes: 1
Reputation: 2332
Finally it worked
.*SET: Global\\[\"test_status\"\\]=(.*)\\r\\n=.*\\r\\n= Ending .*
Upvotes: 0
Reputation: 12334
One problem with using .* is it doesn't stop at the end of the line. Try something like this:
^SET: Global\["test_status"\]=(.*)$
Upvotes: 0