0

I am trying to match the following pattern:

Testcase done, result: {error,
                           {test_case_failed,
                               "Fail: Not all values are as close to expected values."}}

Here, I am using the following regex to match the above pattern:

Testcase\s+done,\s+result:\s+\{(.*?)\}

However, my pattern is not working.

John Rambo
  • 906
  • 1
  • 17
  • 37

2 Answers2

2

Use this instead

Testcase\s+done,\s+result:\s+\{([\s\S]*?)\}

More info about the . (dot) character

Tyress
  • 3,573
  • 2
  • 22
  • 45
  • thanks!! But what is wrong with my expression? How should I use `.* ` to match new line? – John Rambo Feb 26 '16 at 06:36
  • @JohnRambo depends on what language you're using it on.On .NET for example, you have to use [RegexOptions.Singleline](https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regexoptions.aspx), while on Java, [Pattern.DOTALL](http://stackoverflow.com/questions/3222649/any-character-including-newline-java-regex) . You can also do a regex that indicates whether it will match a . or a newline in your in environment (\n in Linux, \r\n in Windows) but all in all [\s\S] is a little less of a hassle IMO – Tyress Feb 26 '16 at 06:41
0

It's simple, as I can see you line can either start with Testcase or a blank space and brace' {' or blank space and quote ' {'

Regex:
Testcase.*|\ {.*| ".*

Check Here

dpanshu
  • 453
  • 3
  • 14