Regex -- String validation

Asked

Viewed 42 times

-1

Good evening, you guys, I’m having trouble forming a Regex that only validates the presence of minute letters and numbers. If anyone could help, I’d really appreciate it! Thank you

  • 1

    simple as that [a-Z0-9]

1 answer

1

^[a-z0-9]*$

Explanation:

  • ^ is the anchor that marks the beginning of a line
  • $ marks the end of a line
  • [a-z0-9] keeps within itself the characters allowed to marry (letras minusculas e números)
  • * may have, may not have, or may have several, infinite, that is, any amount.

for accented

/^[a-z\d\u00E0-\u00FC]*$/

OBS: \d is the same thing as 0-9

  • Adjust your answer to accept accentuation.

  • put in your regex to be more complete

  • me already going Zzzz

  • Never mind. I’m coming. Abs!

    1. Depending on the lib, to accept accents is only by the flag u Unicode. 2. [0-9] can be written as \d

Browser other questions tagged

You are not signed in. Login or sign up in order to post.