Java REGEX to match an exact number of digits in a string

后端 未结 5 1796
天涯浪人
天涯浪人 2020-12-11 04:19

I tried to find the answer to my problem in the questions history but they just come back in more than one thousand and after scanning through a few tens of matching answers

5条回答
  •  粉色の甜心
    2020-12-11 04:54

    The pattern you’re looking for is:

    (?x)              # enable comments
    (?

    That will also pick up things like

    U+FF10 ‭ 0 FULLWIDTH DIGIT ZERO
    U+FF11 ‭ 1 FULLWIDTH DIGIT ONE
    U+FF12 ‭ 2 FULLWIDTH DIGIT TWO
    U+FF13 ‭ 3 FULLWIDTH DIGIT THREE
    U+FF14 ‭ 4 FULLWIDTH DIGIT FOUR
    U+FF15 ‭ 5 FULLWIDTH DIGIT FIVE
    U+FF16 ‭ 6 FULLWIDTH DIGIT SIX
    U+FF17 ‭ 7 FULLWIDTH DIGIT SEVEN
    U+FF18 ‭ 8 FULLWIDTH DIGIT EIGHT
    U+FF19 ‭ 9 FULLWIDTH DIGIT NINE
    

    In case you have those in Chinese text.

提交回复
热议问题