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

后端 未结 5 1597
小鲜肉
小鲜肉 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:34

    I think you can use the | operator of the regex and put the different regexes in paranthesis to be considered one whole regex to be matched.

    ("(P1)|(P2)|(P3)")

提交回复
热议问题