Re: Arrays of strings from regex
| From: | Marek Kilimajer | Date: | Tue, 31 Dec 2002 11:57:21 +0000 |
| Subject: | Re: Arrays of strings from regex | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129762@lists.php.net to get a copy of this message | ||
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.