tel me any 2 regular expressions with example






tel me any 2 regular expressions with example..

Answer / 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




More PHP Interview Questions

In how many ways we can retrieve the data in the result set of mysql using php?

0 Answers  


What is better .net or php?

0 Answers  


For printing out strings, there are echo, print and printf. Explain the differences.

3 Answers  


How to increase the maximum execution time of a script in php?

0 Answers  


What does type casting mean in php? Explain with an example?

0 Answers  






What should we do to be able to export data into an excel file?

0 Answers  


Tell me what is the use of "enctype" attribute in a html form?

0 Answers  


What are objects in php?

0 Answers  


Whether it is possible to share a single instance of a memcache between multiple php projects?

0 Answers  


How can I make a script that can be bilanguage (supports English, German)?

3 Answers  


Why do you need to filter out empty files?

0 Answers  


What is the difference between null and empty?

0 Answers  






Categories