Regular Expressions
preg_match tests a pattern, preg_replace replaces and preg_split splits.
Example
echo preg_match("/^\d{3}-\d{4}$/", "555-1234"), "\n";
echo preg_replace("/\s+/", " ", "a b c"), "\n";
print_r(preg_split("/[,;]/", "a,b;c"));Result
1
a b c
Array
(
[0] => a
[1] => b
[2] => c
)Exercise
Test a pattern.
("/a/", "cat")Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.