java string regex -


Can anyone help me with a piece of regex? I want to stop the user from entering any charger other than az or a hyphen -

Hope someone can help me

thanks

You can use regex: ^ [az-] $

  • ^ : Start anchor
  • $ : and anchor
  • [..] : four squares
  • az : any lowercase alphabet
  • - : a lexical hyphen hyphen usually in four squares A mate Character is, but if the four classes before or last in the form of characters, it is literally behavior.
  • + : Quantifier for one or more

If you want to allow the empty string, then you + with * >


Comments