I write regular expression for alphanumerics, but it is not taking space.
I want space (whitespace between characters).
I write like this:
^[a-zA-Z0-9_]*$
There is the \\s
escape sequence that mean "whitespace".
Change you regex to this (adding whitespace to the list of characters):
^[a-zA-Z0-9_\s]*$
As noted by Alex, \\w
stands for word characters, so you could shorten it further:
^[\w\s]*$
See this handy cheat sheet.
Maybe
^[\w\s]*$
would be shorter?
\\w
means word characters (letters, digits, and underscores).
I prefer this cheat sheet (print).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.