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
How to reset/destroy a cookie?
What are the difference between echo and print?
Explain me what is x+ mode in fopen() used for?
How to calculate the length of a string?
How can we define a variable accessible in functions of a php script?
How to count a number of words in a string in php?
Is it more secure to use cookies to transfer session ids?
Is array function in php?
Tell me how is it possible to remove escape characters from a string?
Explain php split() function.
What is regular expression in javascript?
Which software is best for php?
in PHP for pdf which library used?
How to access a global variable inside a function?
What is the difference between the include() and require() functions?