PHP Regular Expressions

A regular expression or regex is a sequence of characters that forms a search pattern. When you search for data in a text, you can use this search pattern to describe what you are searching for.

Regex are patterns for string matching, with special wildcards that can match entire portions of the target string.

Regular expressions are strings composed of delimiters, a pattern and optional modifiers.

PHP Regex Functions

- preg_match() this funtion returns 1 if the pattern was found in the string and 0 if not found
- preg_match_all() this funtion returns the number of times the pattern was found in the string, which may also be 0 if not found
- preg_replace() this funtion returns a new string where matched patterns have been replaced with another string
- split() this funtion is just like the explode funtion, but it uses regular expression to break or split text instead of literal string.




Next »


Home    |    Learn Programming   |    Learning Management System   |    Computer Based Testing System    |    Contact Us