Why does this Java regex cause “illegal escape character” errors?

前端 未结 6 1870
别那么骄傲
别那么骄傲 2020-11-27 21:28

I\'m working on a solution to a previous question, as best as I can, using regular expressions. My pattern is

\"\\d{4}\\w{3}(0[1-9]|[12][0-9]|3[01])([01][0-         


        
6条回答
  •  生来不讨喜
    2020-11-27 21:49

    I think you need to add the two escaped shortcuts into character classes. Try this: "[\d]{4}[\w]{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}"

    --Good Luck.

提交回复
热议问题