[PHP] Arrays of strings from regex

2002-12-31 Thread David Pratt
Am working through document to collect pieces that match and then insert 
them into an array so they can be used to construct another file.

Looking in my doc for lines like this:

{\*\cs43 \additive \sbasedon10 db_edition;}
{\*\cs44 \additive \sbasedon10 db_editor;}
{\*\cs45 \additive \sbasedon10 db_email;}

Wrote this regex to find them:

^\{\\\*\\?(cs[0-9]{1,3}) (.*)\\[a-z0-9]+ (.*);\}$

Now looking for best method for getting the parts in parenthesis () into an
array so it will contain these values by finding the above three lines:

$matches [0][0][0] = cs43 , \additive \sbasedon10, db_edition
$matches [1][1][1] = cs44 , \additive \sbasedon10, db_editor
$matches [2][2][2] = cs45 , \additive \sbasedon10, db_email

Thanks in advance for any pointers.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Arrays of strings from regex

2002-12-31 Thread Marek Kilimajer


David Pratt wrote:


Am working through document to collect pieces that match and then insert 
them into an array so they can be used to construct another file.

Looking in my doc for lines like this:

{\*\cs43 \additive \sbasedon10 db_edition;}
{\*\cs44 \additive \sbasedon10 db_editor;}
{\*\cs45 \additive \sbasedon10 db_email;}

Wrote this regex to find them:

^\{\\\*\\?(cs[0-9]{1,3}) (.*)\\[a-z0-9]+ (.*);\}$
 

^

I suppose this wants to eat the whole line, use ([^ ]*) - all except space,
or switch to perl expressions with its ungreedy match


Now looking for best method for getting the parts in parenthesis () into an
array so it will contain these values by finding the above three lines:

$matches [0][0][0] = cs43 , \additive \sbasedon10, db_edition
$matches [1][1][1] = cs44 , \additive \sbasedon10, db_editor
$matches [2][2][2] = cs45 , \additive \sbasedon10, db_email

Thanks in advance for any pointers.

 



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php