/cool/
- looks for the first instance of
cool
/cool/gi
- looks for all matches
- case insensitive
/[cp]ool/
- matches
cool
andpool
/[^1]000/
- Match everything except for
1
in the first position 2000
,3000
. . .
/[a-g]/
- instead of writing [abcdefg] we can specify a range
/[a-zA-Z0-9]/
- lowercase, uppercase, and numbers
/[0-9]+/
- match unlimited times, but at least 1
/[0-9]{10}/
- match 10 times
/[0-9]{8,11}/
- match between 8 to 11 times
/[0-9]{8,}/
- match at least 8 times
- match any digit character
[0-9]
- match any word character
[a-zA-Z0-9_]
- match any whitespace character (spaces, tabs)
- match tab character only
/hey?/
- he is a match
- hey is a match
.+
- matches all characters
/^[a-z]{5}$/
- Only find a 5 letter word
- ^ ensures front
- $ ensures back - line end
/cool|pool/
/(c|p)ool/
let reg = /[a-z]/ig
let reg = new RegExp(/[a-z]/, 'ig');
<input pattern="[a-z]">