Regular expressions offer a powerful way to test strings for the presence of patterns. They use a language all their own to describe patterns, a language that consists mostly of symbols. PHP has several functions that use regular expressions.
boolean ereg(string pattern, string text, array matches)
The ereg function evaluates the pattern argument as a regular expression and attempts to find matches in the text argument. If the optional matches argument is supplied, each match will be added to the array. TRUE is returned if at least one match is made, FALSE otherwise.
The first element in the matches array, with an index of zero, will contain the match for the entire regular expression. Subsequent elements of matches will contain the matches for subexpressions. These are the expressions enclosed in parentheses in the example.
string ereg_replace(string pattern, string replacement, string
Use ereg_replace to replace substrings within the text argument. Each time the pattern matches a substring within the text argument, it is replaced with the replacement argument. The text argument is unchanged, but the altered version is returned. If the pattern contains subexpressions in parentheses, the replacement argument may contain a special code for specifying which subexpression to replace. The form is to use two backslashes followed by a single digit, zero through nine. Zero matches the entire expression; one through nine each match the first nine subexpressions, respectively. Subexpressions are numbered left to right, which accounts for nested subexpressions.
boolean eregi(string pattern, string text, array matches)
The eregi function operates identically to ereg with the exception that letters are matched with no regard for upper or lower case.
string eregi_replace(string pattern, string replacement, string text)
The eregi_replace function operates identically to ereg_replace with the exception that letters are matched with no regard for upper or lower case.array split(string pattern, string text, integer limit)
The split function returns an array of substrings from the text argument. The pattern argument will be used as a field delimiter. The optional limit argument sets the maximum number of elements to return. There is no case-insensitive version of split. Compare this function to explode, which uses a simple string to delimit substrings. Regular expression processing is slower than straight string matching, so use explode when you can.<?
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.