Regular expression are used for many things. It whould be complex to write code to check validation.
There is two part:
- The string to search in
- The regular expression
- Regular erxpression starts and end with a
//
- The operator OR is
|
- It can matches letter or number or special character
- There are used mainly for validation, searching, formatting
- Repeat a pattern
/ar+
, the plus operator repeat the letter until there is no more of it. james
andjameasson
- A chartacter set is
[a-z]
, match one character from a to z /[a-z]+/i
i operator is a modifier saying don't care about the case- How to deal with white space
\s
it stands for tabs, space and almost everything. - /[a-z0-9\s]+/i
\w
is the same as[a-zA-Z0-9]
``