tel me any 2 regular expressions with example
Answer Posted / shyambabu
int ereg ( string $pattern , string $string [, array
&$regs ] )
Date Format:YYYY-MM-DD
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date,
$regs)) {
echo "$regs[3].$regs[2].$regs[1]";
prints in dd.mm.yyyy format
} else {
echo "Invalid date format: $date";
}
string ereg_replace ( string $pattern , string
$replacement , string $string )
$num = '4';
$string = "This string has four words.";
$string = ereg_replace('four', $num, $string);
echo $string; /* Output: 'This string has 4 words.'
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Explain Traits in PHP?
What is "print" in php?
Is php front end?
How to increase the maximum execution time of a script in php?
Write a program using while loop in php?
Who is known as the father of php?
What is rest api in php?
How arrays are used in php?
What is the difference between exception::getmessage and exception::getline?
Is php a framework?
What is the difference between get and post method in php?
What is cURL in PHP?
How to write in a file in php?
Is session a cookie?
Explain what does the expression exception::__tostring means?