Test 8a que des chiffres
String : ddd123456
Pattern : /[1-9][0-9]*$/
Match : 1
Test 8b
String : 12345u6
Pattern : /^[0-9]*$/
Match : 0
Test 7a
String : Donny Nguyen
Pattern : [A-Z]
Replacement : [a-z]
Match : Donny Nguyen
Test 7b
String : Donny Nguyen
Pattern : [A-Z]
Replacement : [a-z]
Match : Donny Nguyen
Test 6a match multiple characters
String : PHOJKJP
Pattern : /P.*P/
Match : 1
Test 6b
String : OHOJKJP
Pattern : /P.*P/
Match : 0
Test 6a match a single character
String : PHP
Pattern : /P.P/
Match : 1
Test 6b
String : OHP
Pattern : /P.P/
Match : 0
Test 1a
String : PHP
Pattern : /PHP/
Match : 1
Test 1b
String : PHP
Pattern : /POP/
Match : 0
Test 2a "^" commence par
String : PHP
Pattern : /^PHP/
Match : 1
Test 2b "^" commence par
String : SALUT PHP
Pattern : /^PHP/
Match : 0
Test 3a "$" termine par
String : SALUT PHP
Pattern : /PHP$/
Match : 1
Test 3b "$" termine par
String : SALUT PHP COOL
Pattern : /PHP$/
Match : 0
Test 4a Match for exact string content
String : PHP
Pattern : /^PHP$/
Match : 1
Test 4b Match for exact string content
String : DPHP
Pattern : /^PHP$/
Match : 0
Test 5a Match empty string
String :
Pattern : /^$/
Match : 1
Test 5b Match empty string
String : d
Pattern : /^$/
Match : 0
Test 6a Alphanumeric only (que des chiffres et des lettres
Explanation:
[] => character class definition
^ => negate the class
a-z => chars from 'a' to 'z'
_ => underscore
- => hyphen '-' (You need to escape it)
0-9 => numbers (from zero to nine)