Regex headaches

Everything PHP-related! Discuss scripts, host challenges, request a script, or just ask for plain old help.

Moderators: IRC Operators, Support Team

rangerguy39
User
User
Posts: 397
Joined: Wed Jun 06, 2007 4:06 pm

Regex headaches

Postby rangerguy39 » Mon Nov 10, 2008 11:46 pm

Yeah i'm really dumb with these things. I need a pattern to match 4:rufus!~rangerguy@Swift-5C0610EB.sctnpa.east.verizon.net, or any hostname for that matter. I have this: $nick = preg_match("/\:.\!./", $host, $matches);
but $nick is always 0 and $matches is always an empty array. My regex is probably wrong, so help me please?
Thanks,
rangerguy39
User avatar
Cameron
User
User
Posts: 326
Joined: Fri Aug 11, 2006 8:43 am
Location: Perth, Austalia

Postby Cameron » Tue Nov 11, 2008 2:11 am

preg_match("/:(\S+)!(\S+)@(\S+)!/",$host,$matches);
$matches[1] = rufus
$matches[2] = ~rangerguy
$matches[3] = Swift-5C0610EB.sctnpa.east.verizon.net
Image
Patje
mIRC Guru
mIRC Guru
Posts: 1253
Joined: Sun Dec 17, 2006 2:56 pm
Location: Netherlands

Postby Patje » Tue Nov 11, 2008 6:19 am

Cameron wrote:preg_match("/:(\S+)!(\S+)@(\S+)!/",$host,$matches);
$matches[1] = rufus
$matches[2] = ~rangerguy
$matches[3] = Swift-5C0610EB.sctnpa.east.verizon.net

What's the last exclamation mark?
User avatar
Cameron
User
User
Posts: 326
Joined: Fri Aug 11, 2006 8:43 am
Location: Perth, Austalia

Postby Cameron » Tue Nov 11, 2008 6:56 am

a typo ;)
Image
User avatar
JoshR
User
User
Posts: 716
Joined: Tue Jan 01, 2008 7:32 pm
Location: #mSL
Contact:

Postby JoshR » Tue Nov 11, 2008 2:49 pm

Cameron wrote:a typo ;)


lol
Image

Return to “PHP”

Who is online

Users browsing this forum: No registered users and 1 guest