Home > Courses > Web development using PHP and MySQL > PHP Regular Expressions

PHP Regular Expressions

Subject: Web development using PHP and MySQL
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 function returns 1 if the pattern was found in the string and 0 if not found.

preg_match_all() this function returns the number of times the pattern was found in the string, which may also be 0 if not found.

preg_replace() this function returns a new string where matched patterns have been replaced with another string.

split()  this function is just like the explode function, but it uses regular expression to break or split text instead of literal string.


By: Benjamin Onuorah

Comments

No Comment yet!

Login to comment or ask question on this topic


Previous Topic Next Topic

Supported by