Java comparing string to regex - while loop

后端 未结 2 1869
梦谈多话
梦谈多话 2021-01-21 05:48

I want the user to enter a string and if the string does not match my regex expression then I want a message to be outputted and the user to enter a value again.

The pro

2条回答
  •  北海茫月
    2021-01-21 06:23

    The equals methods checks for string equivalence, not for matching regular expressions.

    Just replace equals with matches. You should also remove the outer square brackets.

提交回复
热议问题