Sandah Aung Sandah Aung - 1 year ago 46
Java Question

Regex for character range and space

I use the following to check if a given string

is within a certain character range:


However, this does not allow for the inclusion of space characters in the name. If I want the user to type space in the name and at the same time want the matcher to return true what would the regex be?


This works fine for me


but this doesn't

enter image description here

Answer Source

I would use:


(don't forget to escape \)