Link to home
Start Free TrialLog in
Avatar of MeridianManagement
MeridianManagementFlag for United States of America

asked on

A couple simple perl compatible regular expressions using php's preg_replace function.

Part 1

Okay, I'm trying to wipe out all dollar values from a string. It's driving me insane. I have no idea what I'm doing...

I tried..  $html = preg_replace("\$[0-9]+.[0][0]",'',$html);

Please help!

<td>PKG</td><td>Sport Lite Package (1 @ $254.00)</td><td align="right">$254.00</td>

Part 2.

$4,543.00    AVS85X17DS2  
    $4,917.00    AVS85X17DS2  
    $4,543.00    AVS85X17DS2  
    $21,896.00    EG85X28WT4  
    $6,390.00    KLS7X20WT3  
    $4,723.00    RT7X16WT2  

I'm looking to extract sizes from the top... I don't exactly know what to do... but here are the real values I'm trying to extract

85X17
85X17
85X17
85X28
7X20
7X16

It seems like the sizes are surrounded by alpha.
ASKER CERTIFIED SOLUTION
Avatar of MasonWolf
MasonWolf
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MeridianManagement

ASKER

Great, but I can't get the second part to work... I'll keep trying.
"$text" in the second statement is supposed to be the string containing your data including the data about sizes.

Thanks for the clarification ozo, I'd forgotten about the thousands separators.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mjcoyne
mjcoyne

The output of the above script, when run against your sample data as indicated, is:

85X17
85X17
85X17
85X28
7X20
7X16
Thanks everyone! What was actually wrong was the quotation. Php doesn't like double quotes for preg functions. Great job!