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

前端 未结 8 1843
孤街浪徒
孤街浪徒 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:44

    Regular Expressions are not needed here. Try this:

    if((string1.toUpperCase().indexOf("ERROR",0) >= 0 ||  
      string1.toUpperCase().indexOf("WARNING",0) >= 0 ) &&
      string1.toUpperCase().indexOf("PARSING",0) >= 0 )
    

    This also takes care of the case-insensitive criteria

提交回复
热议问题