Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REGEXP in string search 1

Status
Not open for further replies.

ejennings

Programmer
Apr 24, 2003
2
CA
I am trying to perform a search using REGEXP on a part number field in a parts table, where some of the parts have dashes. i.e. NZ-23456 I need to ignore the dashes.

It is common for the customer to enter the beginning of a part number, such as "NZ2", and the part number NZ-23456 must be returned.

I have been trying to use regular expressions, but I have not found anywhere where you can ignore a specific character WHEN you do not know its position. The trick is, the dash could be anywhere in the part number string.

Are there any regular expression guru's out there?

Thanks, Eric
 
Code:
select * from t
 where replace(c,'-','') like 'N22%'

will probably be slow though.
 
swampBoogie:

very good, it works. I had to make a slight mod though, as I need with and without the dash, so here it is:

select * from t
where c like '$partNum%' replace(c,'-','') like 'partNum%'

Thanks, Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top