get email address from text

Discussion in 'PHP' started by t6werserv, Jun 16, 2012.

  1. #1
    I want to help get email address from the ranks of text
    How to work on it ??

    ex:

    I want to help get [xxxxx@hotmail.com] from the ranks of text


    echo "xxxxx@hotmail.com";
     
    t6werserv, Jun 16, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Which are you more comfortable with, brute force string manipulation or regular expressions?
     
    Rukbat, Jun 16, 2012 IP
  3. t6werserv

    t6werserv Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes regular expressions
     
    t6werserv, Jun 16, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    Rukbat, Jun 16, 2012 IP
  5. t6werserv

    t6werserv Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    good and code php ?
     
    t6werserv, Jun 16, 2012 IP
  6. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #6
    
    preg_match_all("~^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$~",$text,$matches);
    
    Code (markup):
    NB: This code won't work with custom tld's longer than 6 characters.
     
    ssmm987, Jun 17, 2012 IP
  7. t6werserv

    t6werserv Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    thank you ssmm987
    but i tried the method did not work mobile numbers (11 digit):

    preg_match("/^[0-9]+$/", $text, $matches);
     
    t6werserv, Jun 17, 2012 IP
  8. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #8
    Mobile numbers aren't email addresses, you can't use the RegEx for one to find the other. The site I linked to has all you need to do phone numbers too, but it's a different RegEx.
     
    Rukbat, Jun 17, 2012 IP
  9. t6werserv

    t6werserv Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    code : preg_match("/^[0-9]+$/", $text, $matches);

    not work , why?
     
    t6werserv, Jun 17, 2012 IP
  10. NetStar

    NetStar Notable Member

    Messages:
    2,471
    Likes Received:
    541
    Best Answers:
    21
    Trophy Points:
    245
    #10
    Custom TLDs aren't something to be worried about. The fee is $185,000 with a $25,000 yearly fee. The only companies that can afford it are most likely those already established with an online .com presence. But besides that...even if major companies start switching over ALL of your email providers do not use a custom TLD. This shouldn't be a concern of anyones quite yet...
     
    NetStar, Jun 17, 2012 IP
  11. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #11
    Rejecting a user's email address because it uses a custom tld is something one should never do.
     
    Rukbat, Jun 18, 2012 IP
  12. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #12
    ICANN has received more than 2000 applications for custom TLD's. I would plan for them being commonplace in the next 5 years.
     
    jestep, Jun 18, 2012 IP