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

Explain scalar type declarations in php7?

0 Answers  


What is strlen php?

0 Answers  


List the different types of print functions available in php?

0 Answers  


What is the importance of parser in php?

0 Answers  


write function of the sentence traversal passing the parameter, e.g input:this is input sentence. output:sentence input is this.

1 Answers   HyperQuality,






What is the use of return in php?

0 Answers  


What is polymorphism in php?

0 Answers  


Which Scripting Engine PHP uses?

0 Answers  


What is the php function that removes the first element of the array and returns it?

0 Answers  


How to receive a cookie from the browser?

0 Answers  


What is the meaning of a final class and a final method?

0 Answers  


Is overloading possible in php?

0 Answers  


Categories