Comments

: I had a program that loads a document. I want to get all email addresses from the document.: : I need the regular expression to acomplish this task.: [red]Good luck![/red]: [blue]Hackman[/blue]:

I'm not sure if there's any chance of invalid addresses but here's something to get you started. And I'm sure the more advanced regex guys will post their revisions:[code]if ($email_address =~ /(@.*@)|(..)|(@.)|(.@)|(^.)/) { print "Email is invalid";}elsif ($email_address =~ /^.+[_*]@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,4}|[0-9]{1,4})(]?)$/) { print "Email is valid";}[/code]

--------------: : I had a program that loads a document. I want to get all email addresses from the document.: : : : I need the regular expression to acomplish this task.: : [red]Good luck![/red]: : [blue]Hackman[/blue]: : : : I'm not sure if there's any chance of invalid addresses but here's something to get you started. And I'm sure the more advanced regex guys will post their revisions:: [code]: if ($email_address =~ /(@.*@)|(..)|(@.)|(.@)|(^.)/) {: print "Email is invalid";: }: elsif ($email_address =~ /^.+[_*]@([?)[a-zA-Z0-9-.]+.([a-zA-Z]{2,4}|[0-9]{1,4})(]?)$/) {: print "Email is valid";: }: [/code]:

: : And I'm sure the more advanced regex guys will post their revisions:: Or maybe just a good way to extract all of the addresses and put them in an array with one line of code...: : push @addrs, $1 while $text =~ /([w-.]+@[w-.]+.w+)/g;: : Where @addrs is an array to put the addresses in and $text is the text in the document.: : XFactor's solutiion probably does fine, but figured I'd show off...uh...I mean, post how I'd do it. :-): : Jonathan: : ###: for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&: (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;: /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");: :