mercredi 1 décembre 2021

how to format the search query to remove special characters while searching mobile number, REGEXP_REPLACE

As my table was contacts which contains data in us format as(###)-###-#### and there were input field in which user enters the normal string format of ######

this was my current query

contacts.where("REGEXP_REPLACE(contacts.phone_number,'[^0-9A-Za-z]','','g') ilike :search", {search: "%#{mob_num}%"})

so as it doesn't fetch any data, while giving the correct input also, what was wrong in my query, as i try to modify the data in normal format for searching the phone number in table...

please provide a solution for it

thanks in advance

Aucun commentaire:

Enregistrer un commentaire