|
-
May 12th, 2007, 07:14 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] preg_match
Can anyone explain this little for e about the regular expr.
PHP Code:
"/^(http:\/\/info@)?([^\/]+)/i"
I understand the first part, but after the "?" I dont' get it.
-
May 12th, 2007, 11:57 PM
#2
Lively Member
Re: preg_match
match any character that isn't a "/" as many times as possible (greedy)
-
May 13th, 2007, 01:54 AM
#3
Thread Starter
Frenzied Member
Re: preg_match
I still don't get it, what do you mean. Could you give me an example of a phrase or a URL?
-
May 13th, 2007, 03:53 AM
#4
Re: preg_match
^ 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|