Regular Expressions 101

Save & Share

  • Save Regex
    ctrl+s
  • Update Regex
    ctrl+⇧+s

Flavor

  • PCRE2 (PHP >=7.3)
  • PCRE (PHP <7.3)
  • ECMAScript (JavaScript)
  • Python
  • Golang
  • Java 8

Function

  • Match
  • Substitution
  • List
  • Unit Tests
/
^(?=.*[a-záéíóúñ])(?=.*[A-ZÁÉÍÓÚÑ])(?=.*[0-9])\S{8,16}$
/
gm
^ asserts position at start of a line
Positive Lookahead
(?=.*[a-záéíóúñ])
Assert that the Regex below matches
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[a-záéíóúñ]
a-z matches a single character in the range between a (index 97) and z (index 122) (case sensitive)
áéíóúñ
matches a single character in the list áéíóúñ (case sensitive)
Positive Lookahead
(?=.*[A-ZÁÉÍÓÚÑ])
Assert that the Regex below matches
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[A-ZÁÉÍÓÚÑ]
A-Z matches a single character in the range between A (index 65) and Z (index 90) (case sensitive)
ÁÉÍÓÚÑ
matches a single character in the list ÁÉÍÓÚÑ (case sensitive)
Positive Lookahead
(?=.*[0-9])
Assert that the Regex below matches
.
matches any character (except for line terminators)
* matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)
Match a single character present in the list below
[0-9]
0-9 matches a single character in the range between 0 (index 48) and 9 (index 57) (case sensitive)
\S
matches any non-whitespace character (equivalent to [^\r\n\t\f\v \u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff])
{8,16} matches the previous token between 8 and 16 times, as many times as possible, giving back as needed (greedy)
$ asserts position at the end of a line
Global pattern flags
g modifier: global. All matches (don't return after first match)
m modifier: multi line. Causes ^ and $ to match the begin/end of each line (not only begin/end of string)
Your regular expression does not match the subject string.

Regular Expression
No Match

/
/
gm

Test String