How to find if a Java String contains X or Y and contains Z

前端 未结 8 1840
孤街浪徒
孤街浪徒 2021-01-06 11:03

I\'m pretty sure regular expressions are the way to go, but my head hurts whenever I try to work out the specific regular expression.

What regular expression do I ne

8条回答
  •  生来不讨喜
    2021-01-06 11:42

    I usually use this applet to experiment with reg. ex. The expression may look like this:

    if (str.matches("(?i)^.*?(WARNING|ERROR).*?parsing.*$")) {
    ...
    

    But as stated in above answers it's better to not use reg. ex. here.

提交回复
热议问题