regex space character code example

Example 1: whitespace regex

\s is the regex character for whitespace. It matches spaces, new lines, carriage returns, and tabs.

Example 2: regex tab

Regex of tab representation:
[ \t]

Example 3: space allow in regex

Just add a space in your character class.

^[a-zA-Z0-9_ ]*$

Example 4: regex for letters and spaces

/* Note this works with the onkeyup function in html with js */

function lettersandSpacesOnly(input){
    var regexs = /[^a-z ]*$/gmi;
    input.value = input.value.replace(regexs, "");
  }