how to explain such a regular syntax
| From: | win.a | Date: | Fri, 13 Aug 2010 06:47:14 +0000 |
| Subject: | how to explain such a regular syntax | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-47304@lists.php.net to get a copy of this message | ||
Its was picked from drupal source code and i don't know how does it works.
This is the code :
preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $host);
After followed the regular syntax ,i try to cut it into pieces to make
it simpler to
understand ,
part a1: ^\[?
part a2:([a-z0-9-:\]_]+\.?)+$
Then go on cut part a2:
a2_1: ?:
a2_2: ([a-z0-9-:\]_]+\.?)+$
a2_3: a2_2 and +$
a1 means:start with nothing or one "?"
a2_2 means character must be in a-z,0-9 ,"]","_" and the number must
be only one
a2_3 means there must be one and only matched a2_2 string .
And i dint't got a2_1 mean.
Anyone could explain the it works and the fault of my analysis are appreciated!
All you best
------------------------
What we are struggling for ?
The life or the life ?