Java regular expression word match

前端 未结 5 640
孤街浪徒
孤街浪徒 2021-01-25 15:05

I have 3 values IU, PRI and RET. if my input string contains any one or more value(s),
the Java regular expression should return true.

5条回答
  •  庸人自扰
    2021-01-25 16:01

    You could do this in one line and get your boolean value.

    boolean matcher = Pattern.matches("[UI]{2}|[PRI]{3}|[RET]{3}", stringToBeMatched);

提交回复
热议问题