PHP » PYTHON |
login |
register |
about
|
Like PHP example:
import re date = '2010-05-17' search = re.search('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})', date) if search: regs = search.groups() print '{2}.{1}.{0}'.format(regs[0], regs[1], regs[2]) else: print 'Invalid date format:', date ereg(PHP 4, PHP 5) ereg — Regular expression match Description
int ereg
( string $pattern
, string $string
[, array &$regs
] )
Searches a string for matches to the regular expression given in pattern in a case-sensitive way. Parameters
Return ValuesReturns the length of the matched string if a match for pattern was found in string , or FALSE if no matches were found or an error occurred. If the optional parameter regs was not passed or the length of the matched string is 0, this function returns 1. Examples
Example #1 ereg() example The following code snippet takes a date in ISO format (YYYY-MM-DD) and prints it in DD.MM.YYYY format:
<?php
Notes
See Also
|
more
Recently updated
more
Most requested
more
Last requests
|