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
How does php work?
What happens when submit button is clicked?
Tell me what is the difference between ereg_replace() and eregi_replace()?
What are php data types?
Why is php so popular?
What are the different loops in php?
How can we pass the variable through the navigation between the pages?
What is the difference between Split and Explode in PHP?
How will you calculate days between two dates in PHP?
How can we connect to a mysql database from a php script?
What is php mean?
How can you increase the maximum execution time of a script in php?
What is explode() in php?
Which function would you use to merge two arrays in php?
How do I clear my browser session?