I want to fetch substrings from a GET-string in Javascript to pass them to a query on PostgreSQL. I've tried already with PostgreSQL full text search, but ended up with the problem, that full text search only allows prefix matching (Already described here).
So I'm looking to use the 'ILIKE ALL(array)' with an array of substrings with wildcards.
SELECT * from parcels WHERE doc ilike ALL(array['%substr1%','%substr2%', '%substr3%']);
I split up my GET-string in Javascript like this.
var str = (GET()['search']).split ('+');
which gives me already an array of substrings. How can I add a leading and trailing % to each substring with regEx? Or is there a better way to archieve this?