Branching refers to the formulation of several rules, which, if any of these rules are met, are considered successful matches. Specifically, it's used | The symbols separate the various rules, and the conditions match from left to right. Tips
As a result of branching rules, as long as the match is successful, the following conditions will no longer match, so if you want to match the contents of the containing relationship, please pay attention to the order of the rules.
Here is an example of using a branch.
The rule for the U.S. ZIP Code is 5 digits or 5 digits connected to 4 digits, such as 12345 or 54321-1234, if you want to match all the zip codes, the correct regular expression is:
\D{5}-\D{4}|\D{5}
//Error writing
\d{5}|\d{5}-\d{4}
The following error notation can only match 5 digits and 9 digits of the first 5 digits of the case, and can not match 9-digit zip code.