Hi James, Thank you. That does help. I've been look at PHP.net to get my head around the expression syntax. This help a lot. Thanks.
Sincerely, Mike -- Mike Brandonisio * Web Hosting Tech One Illustration * Internet Marketing tel (630) 759-9283 * e-Commerce [EMAIL PROTECTED] * http://www.jikometrix.net JIKOmetrix - Reliable web hosting On Mar 22, 2007, at 5:25 PM, James Keeline wrote: > --- Mike Brandonisio <[EMAIL PROTECTED]> wrote: > >> That worked. Thank you. I'll play some more. I want to catch domains >> with hyphen and sub domain emails too like [EMAIL PROTECTED] >> >> Thanks again. >> >> Sincerely, >> Mike > > Perhaps if I explained what this regex (regular expression) does, > you could > make some intelligent modifications. > >>> preg_match_all("/[EMAIL PROTECTED]/", $str, $output); > > // The regex is surrounded by / characters. It could be another > character > but the / is traditional. Occasionally I will use a pipe > character (|) > when I have matching content which contains slashes (/) and I > don't care > to use the backslash (\) to escape each one. > > \w Match any letter [a-z] or [A-Z] or digit [0-9] ... [0-9A-Za-z] > > \w+ The plus (+) quantifier says "1 or more" of the match to the > left. In > this case one or more of any character matching [0-9A-Za-z]. > > \. The dot (.) normally means match any character. Since we > want to match > the literal dot character, it must be escaped with the > backslash. In > Perl regex it is often necessary to escape the @ symbol but > not in PHP. > > Effectively this pattern matches for: > > {any [EMAIL PROTECTED] alphanum}.{any alphanum} > > You could use something like: > > [EMAIL PROTECTED] > > to say > > {any [EMAIL PROTECTED] char}.{any char} > > Regex is greedy by default so it will try to make the longest match > possible. > Hence, this could have undesired results as the any char could > match a space or > other characters not legal in email addresses. Here's something a > little more > complete: > > [\w._-]+@([\w-]+\.)+[A-Za-z]+ > > After the @ we have alphanum or a dash followed by a dot. The > parens are used > for grouping but can also have the effect of storing the matching > content in a > regex memory location. The plus after the parens says one or more > of the > pattern in the parens. Since top level domains are just letters > right now, one > or more of those are matched for the end. > > As you can see, regex can look like an alphabet soup of punctuation > marks very > quickly. > > James Keeline > > > > > > Community email addresses: > Post message: [email protected] > Subscribe: [EMAIL PROTECTED] > Unsubscribe: [EMAIL PROTECTED] > List owner: [EMAIL PROTECTED] > > Shortcut URL to this page: > http://groups.yahoo.com/group/php-list > Yahoo! Groups Links > > >
