Invalid escape sequence

后端 未结 3 1423
既然无缘
既然无缘 2021-01-23 21:59

I would like to filter out all words containing 1 number and 3 capital letters with a total length of 4. See my example here: http://gskinner.com/RegExr/?32taa

A         


        
3条回答
  •  生来不讨喜
    2021-01-23 22:14

    Your code has two issues:

    • Your pattern is wrong, as it allows more digits - see http://regexr.com?32u3e

    • Java requires double escape slashes...

    Use regex pattern

    \\b(?=[A-Z]*\\d[A-Z]*\\b)[A-Z\\d]{4}\\b
    

提交回复
热议问题