How do you match multiple Regex patterns for a single line of text in Java?

后端 未结 5 1612
小鲜肉
小鲜肉 2020-12-17 09:05

Lets say I have multiple patterns P1, P2, P3,, and so on. These patterns are different Regex patterns to match different variations of DATE.

How do I match these for

5条回答
  •  时光取名叫无心
    2020-12-17 09:27

    I would not use Patterns to match dates.

    You have DateFormat and SimpleDateFormat classes to do so.

    This said, combining Patterns can be done with the alternation (|) operator on the String representation of the Pattern.

提交回复
热议问题