Using preg_match_all, I need to capture a list of first and last names plus
an optional country code proceeding them.
For example:
<tr><td>AU</td><td>Jane Smith</td></tr>
<tr><td></td><td>Bill Johnson</td></tr>
<tr><td>GB</td><td>Larry Brown</td></tr>
<tr><td>US</td><td>Mary Jordon</td></tr>
<tr><td></td><td>Peter Jones</td></tr>
The country code might exist, it might not.
I would like the array contents to look like this:
AU Jane Smith
Bill Johnson
US Larry Brown
GB Mary Jordon
Peter Jones
I know a subpattern is needed of all the possible country codes:
AU|GB|US
but how do you include this as an optional subpattern?
Thanks in advance.
an optional country code proceeding them.
For example:
<tr><td>AU</td><td>Jane Smith</td></tr>
<tr><td></td><td>Bill Johnson</td></tr>
<tr><td>GB</td><td>Larry Brown</td></tr>
<tr><td>US</td><td>Mary Jordon</td></tr>
<tr><td></td><td>Peter Jones</td></tr>
The country code might exist, it might not.
I would like the array contents to look like this:
AU Jane Smith
Bill Johnson
US Larry Brown
GB Mary Jordon
Peter Jones
I know a subpattern is needed of all the possible country codes:
AU|GB|US
but how do you include this as an optional subpattern?
Thanks in advance.
Comment