Can anyone explain this little for e about the regular expr.
I understand the first part, but after the "?" I dont' get it.PHP Code:"/^(http:\/\/info@)?([^\/]+)/i"
Printable View
Can anyone explain this little for e about the regular expr.
I understand the first part, but after the "?" I dont' get it.PHP Code:"/^(http:\/\/info@)?([^\/]+)/i"
match any character that isn't a "/" as many times as possible (greedy)
I still don't get it, what do you mean. Could you give me an example of a phrase or a URL?
^ is the inversion operator;
\/ is the escaped form of / since the expression uses / as the delimiter;
[] denotes a character class;
[^\/] matches any character that is not /
+ means match at least once;
[^\/]+ means match at least one character that is not /
The i flag means match case-insensitively.
You can make it a bit less ugly by changing the delimiter to something else:
Code:#^(http://info@)?([^/]+)#i