
William R Yoder - 2010-06-23 19:26:49
I've started using the elegant and sophisticated RegEx module.
However, the simplest task seems not to work. I have a multi-line string, $tcontents, like this:
<tr>
<td>__Salutation.asp</td>
<td>__1st name.asp</td>
<td>__last name.asp</td>
<td>__st. address.asp</td>
<td>__city.asp</td>
<td>__state.asp</td>
<td>__zip.asp</td>
</tr>
I want to replace it with a string like this:
<tr>
<th>Salutation</th>
<th>1st name</th>
<th>last name</th>
<th>st. address</th>
<th>city</th>
<th>state</th>
<th>zip</th>
</tr>
Should be easy, right?
This invocation partially works:
$regexp=new regexpBuilder();
$regexp->match(CHAR)
->frequency(ONE_OR_MORE) //match desired word
->ifItIs(FOLLOWED_BY) //start condition
->match(".asp") //if it's followed by "def"
->closeIf() //close condition
->ifItIs(PRECEEDED_BY) //start condition
->match("__") //if it's preceeded by "__"
->closeIf(); //close condition
$matches=$regexp->execOn($tcontents);
However, it misses any matches that have digits or periods.
I've tried various combinations:
matchOneOfTheseChars
DIGIT_CHAR
NON_GENERAL_SPACE_CHAR
LETTER_CHAR.DIGIT_CHAR."."
They all fail to match.
Any advice? Thanks!