A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Regulat Expression trouble

  1. #1
    the usual
    Join Date
    Jul 2000
    Posts
    1,482

    Regulat Expression trouble

    I'm trying to parse a e-mail addy and break it up into segments

    I want:
    PHP Code:
    Array
    (
        [
    0] => [email]tman@somewhere.com[/email]
        [
    1] => tman
        
    [2] => somewhere.com

    here's my current attempt

    PHP Code:
    $f '/([^@\s]+@)([-a-z0-9]+\.)+([a-z]{2,})/i';
    $string 'tman@somewhere.com';
    preg_replace_callback($f'test'$string);
            
    function 
    test $matches ) {
        
    print_r ($matches);
    }
    /*
    prints out
    Array
    (
        [0] => [email]tman@somewhere.com[/email]
        [1] => tman@
        [2] => somewhere.
        [3] => com
    )*/ 
    any ideas?
    thanks

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    a little reordering (untested)

    $f = '/([^@\s]+)@(([-a-z0-9_]+\.)+([a-z]{2,}))/i';

    I have added the _ which I believe is legal in domain names. Also. I guess the user part should be somewhat more restricted

    Musicman

  3. #3
    the usual
    Join Date
    Jul 2000
    Posts
    1,482
    perfect, thanks mate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center