can we check multiple patterns using regex in java?

java, regex

Solution

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`

Problem

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?

Original source