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


Please Help Members By Posting Answers For Below Questions

What does == mean in php?

522


Which character is used to match exactly one character?

554


Is php required for wordpress?

510


can we swap two different string using php for example:-- before swapping:-- 1 string :-hello friend, 2 string :-my dear, after swapping that strings will be: 1.hello dear, 2.my friend.

3075


What is the purpose of php?

547






Do you know what is php?

555


What is $row in php?

542


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

559


Explain how is it possible to set an infinite execution time for php script?

515


How can we upload a file in php?

539


What is difference between required and require_once in php?

548


What does addslashes do in php?

542


What is php form validation?

559


What is the use of mysql_fetch_assoc in php?

516


Code to upload a file in PHP?

561