[thelist] php pattern matching
Anthony Baratta
anthony at baratta.com
Sun Feb 13 12:16:01 CST 2011
On 2/13/2011 9:39 AM, Bob Meetin wrote:
> {12345|tom smith|whatever title} oh what a beautiful morning, yadda yadda
RegEx
^{(.*)}(.*)$
When you check the Matches object, you should have
$1 :: 12345|tom smith|whatever title
$2 :: oh what a beautiful morning, yadda yadda
This assumes you don't have any returns/line feeds in your "text" area.
e.g.
<?php
$ptn = "/^{(.*)}(.*)$/";
$str = "{12345|tom smith|whatever title} oh what a beautiful morning,
yadda yadda ";
preg_match($ptn, $str, $matches);
print_r($matches);
?>
Array
(
[0] => {12345|tom smith|whatever title} oh what a beautiful
morning, yadda yadda
[1] => 12345|tom smith|whatever title
[2] => oh what a beautiful morning, yadda yadda
)
--
Anthony Baratta
Capitalism is a "perennial gale of creative destruction."
-- Joseph Schumpeter
More information about the thelist
mailing list