POSIX and PCRE help
| From: | OrangeHairedBoy | Date: | Sat, 16 Nov 2002 07:20:12 +0000 |
| Subject: | POSIX and PCRE help | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-124704@lists.php.net to get a copy of this message | ||
I am trying to learn more about regular expressions as I haven't used them
much in the past. I am working with email, and I'm looking for a way to
split the following expression up:
Content-Type: text/plain; boundary="whatever";
Using "/^(\S+)\:\s*(.+)$/iU" I can split it into:
[Content-Type] and [text/plain; boundary="whatever";]
Problem is, it might have different tags. Here's a sketch of the whole
thing:
[Header Name a-zA-Z0-9] [\s*] [:] [\s*] [ Header value a-zA-Z0-9/_ ] [\s*]
[;] [ unlimited repeating pattern of ( [Property Name a-zA-Z0-9] [\s*] [=]
[\s*] ( string optionally surrounded by quotes - but necessary if value has
spaces - but can't include quotes ) [\s*] [;] ) ]
So, if I had:
User: JohnDoe; age=32; nickname="Billy 'the' Kid"; haircolor=orange;
I would need:
User - "JohnDoe" - age - "32" - nickname - "Billy 'the' Kid"
- haircolor -
"orange"
in the outputted array. I have no idea how to do repeating patterns like
this...maybe I'm making this too complex?
Thanks for your help!
Lewis