Java: removing numeric values from string

前端 未结 7 1900
心在旅途
心在旅途 2020-12-01 18:03

I have suceeded with the help of this community in removing numeric values from user input, however, my code below will only retrieve the alpha characters before the numeric

7条回答
  •  臣服心动
    2020-12-01 18:26

    Your regex:

    [^A-Z]
    

    matches anything which is not an uppercase letter.

    Which means any lowercase letter will match too.

    You should probably use:

    [^A-Za-z]
    

    as a regex instead.

    Note also that this will not account for anything other than ASCII. It may, or may not, be what you want.

提交回复
热议问题