Any preg_match experts out there ?
I need a regex to figure out if a person's name (part of an email address) is RFC2047 encoded or not using the php function preg_match()
* For example
* =?ISO-8859-1?Q?Andr=E9?= Pirard
* The example above is taken from the rfc2047 document, and appears in a CC:
* CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
* For reference: RFC 2047 - MIME (Multipurpose Internet Mail Extensions) Part Thr (RFC2047)
I have already separated the name part from the email address - so the pattern does not need to look for the email address part.
As I understand it, the pattern for an encoded name is
Charset: character set name - presumably A-Za-z0-9 and the "-" character. I am not aware of any other characters in charset names ??
Encoding: B (for base64) or Q (for Quoted printable) - probably b or q acceptable here too
Encoded Text: The encoded part of the text which can be either base64 or quoted-printable characters - A-Za-z0-9/+ (base64) or All printable ASCII characters (quoted-printable)
Unencoded part: Optionally the above could be followed by additional words that contain all ASCII characters that are not encoded - as in the example above where just the first name is encoded - and the last name is not.
I would be very grateful is someone out there who understands these well could provide the appropriate regex pattern.
Or if anyone has a better alternative way to do this - I would be delighted to know that too.