I am working on search section where comparing input values with the stored records. Database having value like AB 09 C D 1234. I have explode (with space) input string to match with stored value but when I given input like AB09 CD 1234, it does not result above record.
SELECT * FROM some_vehicle WHERE vehicle_number ILIKE E\'%AB09 CD 1234%'
vehicle_number in db: AB 09 C D 1234
input string: AB09 CD 1234
I want to result having every possible scenario with combination of input string. Is there any way to do that in PostgreSQL?
"replace" function able to eliminate blank space from the string. Is there any way in PostgreSQL to eliminate all special characters too along with blank space. I was trying different regular expressions like
regexp_replace(vehicle_number,'[^a-z0-9\s]', '') and regexp_replace(vehicle_number,'[(|-|)|\:|\@|#|\$|*|.|!|\,]', '') but its not working.
Thanks
Figured it out after few attempts! was very close to it. "[^a-zA-Z0-9]" pattern eliminate all special characters including space with 'g' option as the fourth parameter of regexp_replace in PostgreSQL.