Invalid regular expression : Dangling meta character “*”

后端 未结 2 1500
猫巷女王i
猫巷女王i 2021-01-25 10:07

I am creating an identification window with login and username for JavaFX, and I am using regex to make sure that the password contains at least one special character and one di

2条回答
  •  甜味超标
    2021-01-25 11:08

    In regular expressions, the Kleene star * means "zero or more matches of the preceding character (class) or group". But in your case, there is nothing preceding, the star is the first character in your regex string. That's what the error indicates.

    If you actually want to match an asterisk you have to escape it with backslashs:

    "\\*\\d+.*\\W+.*"
    

提交回复
热议问题