0

I'm new here, and I'm working on a student project

I need a regular expression for "at least one word"

Should it be \w+ ??

macropod
  • 12,757
  • 2
  • 9
  • 21
  • A similar question has been asked before :) https://stackoverflow.com/questions/25131949/regex-for-one-or-more-words-separated-by-spaces – Alex.Gunning May 31 '21 at 10:38
  • Does this answer your question? [Regex for one or more words separated by spaces](https://stackoverflow.com/questions/25131949/regex-for-one-or-more-words-separated-by-spaces) – rohatgisanat May 31 '21 at 10:46

1 Answers1

0

\w stands for “word character”. It always matches the ASCII characters [A-Za-z0-9_]

https://www.regular-expressions.info/shorthand.html

So [A-Za-z]+ should probably be better. Note that it will be ok for word from only one letter.

Dri372
  • 1,275
  • 3
  • 13