Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

qucik php regular expression question

Options
  • 16-06-2006 3:29pm
    #1
    Registered Users Posts: 648 ✭✭✭


    hi
    can anyone tell me how to select all the names from a lump of text considering all the names are surronded by [[ ]]


    qsdk qsd qs john qkjsd jksqjkdsq mary qskdjh sqkjdhsqhjsdq s james


    Thank you


Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    very simply ...

    <?php
    $subject = "qsdk qsd qs [[john]] qkjsd jksqjkdsq [[mary]] qskdjh sqkjdhsqhjsdq s [[james]]";
    $pattern = '/\[\[(\w+)\]\]/';
    preg_match($pattern, $subject, $matches);
    print_r($matches);
    ?>
    

    doesn't have any bells or whistles on it ...


Advertisement