how to explain such a regular syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux