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 is php and its advantages?

0 Answers  


What is $_ env in php?

0 Answers  


How to copy a file?

0 Answers  


What is __ construct in php?

0 Answers  


What is the meaning of a persistent cookie?

0 Answers  






So if md5() generates the most secure hash, why would you ever use the less secure crc32() and sha1()?

0 Answers  


What are encryption functions in php?

0 Answers  


How do you run a php script from the command line?

1 Answers  


Explain about Functions in PHP?

1 Answers  


How can we upload a file in php?

0 Answers  


What is php variable?

0 Answers  


How do you execute a php script from the command line?

0 Answers  


Categories