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

Which is better python or php?

555


discuss the issue of software theft in ghana and how it has affected the economy

1667


Can we use get instead of post?

492


What is ci framework in php?

495


Distinguish between urlencode and urldecode?

547






What is url encoding and decoding in php?

547


Where php language is used?

522


How to get length of an array in PHP?

561


What is htaccess? Why do we use this and where?

488


How can I display text with a php script?

469


Which programming language does php resemble to?

528


What are the new features available in php 7?

536


Do while loops?

519


How values in arrays are indexed?

591


Why did you choose this particular career path?

8347