can we check multiple patterns using regex in java?

后端 未结 2 1887
广开言路
广开言路 2021-01-13 10:13

i want to check 2 patterns using regex.

can i check those both patterns in the same time (like if(condition1 | condition2) condition).

any idea?

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 11:03

    You can do it exactly the way you did, with pipe separating the two+ expressions

    For instance: The regular expresion (abc)|(def) would match abc OR def

提交回复
热议问题