Re: Parsing

From: Date: Mon, 23 Feb 2015 06:17:28 +0000
Subject: Re: Parsing
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-324502@lists.php.net to get a copy of this message
Thank you. Can you explain what (.*?)(\s*?) do? Ron On 23/02/15 00:36, Jigar Dhulla wrote:
http://refiddle.com/24zw <?php preg_match('/Sent to(.*?)(\s*?)On(\s)(\d){2}-(\d){2}-(\d){2}(\s)(\d){2}\:(\d){2}(\s)(AM|PM),(.*?)(wrote:)/ig', $correspondence, $matches); var_dump($matches); ?> On Mon, Feb 23, 2015 at 10:03 AM, Ron Piggott <ron.piggott@actsministries.org <mailto:ron.piggott@actsministries.org>> wrote:
    I am wondering if someone could help me parse the text that
    appears above
       "On 15-02-19 02:31 PM, The Verse of the Day Inquiries wrote:"
    from the variable"  $correspondence "
       $correspondence = <<<EOF
       Looking to see if this message is appended to the original ticket #
       3784.
       Sent to inquiries@theverseoftheday.info
    <mailto:inquiries@theverseoftheday.info>
       On 15-02-19 02:31 PM, The Verse of the Day Inquiries wrote:
*=== To reply please type your response ABOVE THIS LINE ===*
       EOF;
    What I have worked out so far is:
       if ( strpos( $correspondence , '=== To reply please type your
       response ABOVE THIS LINE ===' ) ) {
            $correspondence = substr(
                $correspondence,
                0,
                strpos(
                    $correspondence,
                    '=== To reply please type your response ABOVE THIS
    LINE
       ==='
                )
            );
       }
    The date time and business e-mail account name will be dynamic.     The type of pattern to match would be
    - starting with "On"
    - ending with "wrote:"
    Thank you for any help / guidance.
-- Regards, Jigar Dhulla


« previous php.general (#324502) next »