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

what are Implode and Explode functions?

8 Answers   HCL,


Tell us what does $_cookie means?

0 Answers  


What is the purpose of the following files having extensions 1) .frm 2) .myd 3) .myi? What do these files contain?

2 Answers  


Is php deprecated?

0 Answers  


Where do we use get and post?

0 Answers  






How to increase the execution time of a PHP script?

0 Answers  


I am working in VFP with no knowledge of web programming.I want to learn web database programmin. Can I choose PHP and MYSQL for that?

2 Answers  


Explain the different types of errors in php.

0 Answers  


What is php default argument?

0 Answers  


How can I embed a java programme in PHP file and what changes have to be done in PHP.ini file?

1 Answers   Sify, Small Biz Express,


Do I need apache for php?

0 Answers  


How does php work with apache?

0 Answers  


Categories