Regex Pattern

Discussion in 'Developers' Forum' started by Horfic, Jan 12, 2010.

  1. Horfic

    Horfic Member

    Hi,
    I'm having troubles figuring the regex pattern out for this here:
    cc “!info@example.tld”

    The email is changing the cc “{email}” stays always the same.

    So what would it be so I can extract the email out of this string.

    PS: This is just an extract from the custom_mailfilter, so there is more text around it.
     
  2. Ben

    Ben HowtoForge Supporter

    maybe this gives you a hint:

    PHP:
    <?php

    $str 
    "asdasasasd cc \"!info@example.tld\"  asdasdasdsad";

    if( 
    preg_match("/cc \"(.*)\"/"$str$matches) ) {
       
    var_dump($matches);
    }
    else {
       
    //String was not found
    }

    ?>
    where $matches[1] would be the string within "". You might also think of using another regex to match a more or less real syntax for emailadresses instead of matching any string between "" ( -> (.*) ).
     

Share This Page