I want to restrict the user from entering a tab in a text field using regular expression.
1 Answer
[ ]{2,}
It will check 2 or more spaces You could also check that before and after those spaces words follow. (not other whitespace like tabs or new lines)
\w[ ]{2,}\w
The same, but you can also pick (capture) only the spaces for tasks like replacement
\w([ ]{2,})\w
or see that before and after spaces there is anything, not only word characters (except whitespace)
[^\s]([ ]{2,})[^\s]
To be specific about Tab, you can use. It will check 1 or more that once tab
[ \t]{1,}