Jump to content


Photo

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


  • Please log in to reply
3 replies to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 19 June 2006 - 12:11 PM

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?


#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 19 June 2006 - 12:12 PM

Can't you just run a str_replace("-","",$string) on it beforehand?

#3 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 19 June 2006 - 02:50 PM

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

Went with this:


$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)

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






#4 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 19 June 2006 - 02:56 PM

To make things easier, you can use arrays as parameters within str_replace()

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users