Jump to content

Archived

This topic is now archived and is closed to further replies.

AV1611

I Hate regex... Need help (Again!)

Recommended Posts

I am doing a query where one data source has this Part Number

12-112-21

and the other has this:

1211221

gotta get rid of the dashes, I guess... can't use wildcards in the query, obviously...

Suggestions?

Share this post


Link to post
Share on other sites
Can't you just run a str_replace("-","",$string) on it beforehand?

Share this post


Link to post
Share on other sites
[!--quoteo(post=385603:date=Jun 19 2006, 08:12 AM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ Jun 19 2006, 08:12 AM) [snapback]385603[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Can't you just run a str_replace("-","",$string) on it beforehand?
[/quote]

Went with this:

[code]

$MFG=$row['MFG'];
$MFGa=str_replace(".","%",$MFG);
$MFGa=str_replace("-","%",$MFGa);
$MFGa=str_replace(" ","%",$MFGa);


$MFG1=$row1['MFG1'];
$MFG1a=str_replace(".","%",$MFG1);
$MFG1a=str_replace("-","%",$MFG1a);
$MFG1a=str_replace(" ","%",$MFG1a);

IF ($MFG1a==$MFGa && $MFG1_PNa==$MFGPNa)
[/code]

This got most of them, but I still have some oddballs that I dont 'know what to do with:

here are some examples if anyone has a suggestions - These are all synonimous<sp?>:

3M
3M CO
3M CO-LF
3M COMPANY
3M SCOTCH
3M/TEXTOOL
3M\SCOTCH
3M-LF

ACCURATE SCREW
ACCURATE SCREW CO.
ACCURATE SCREW MACHINE
ACCURATE SCREW MACHINE CO

VISHAY
VISHAY LITEON
VISHAY RESISTORS
VISHAY ROEDERSTEIN
VISHAY SILICONIX
VISHAY SPRAGUE
VISHAY VITRAMON
VISHAY/DALE
VISHAY/LITEON
VISHAY/OHMTEK
VISHAY/TELEFUNKEN
VISHAY-BCC
VISHAY-LITEON
VISHAY-SILICONIX
VISUAL SYSTEMS




Share this post


Link to post
Share on other sites
To make things easier, you can use arrays as parameters within str_replace()

[code]$MFG=$row['MFG'];
$MFGa=str_replace(array("."," ","-"),"%",$MFG);[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.