bocoup / skillsbot

Skill Tracking Bot
2 stars 0 forks source link

Greedy Regex #81

Closed MattSurabian closed 7 months ago

MattSurabian commented 8 years ago

image

Fuzzy search is well and good but this is maybe too fuzzy

cowboy commented 8 years ago

Right now, we're just using ILIKE '%git%' in the SQL query, but additional logic could be added in the JavaScript to further filter out bad matches.

Here's a basic example:

const search = 'git';
const queryResults = ['Git', 'Digital', 'My Git Example', 'Gitosis'];

const re = new RegExp(`\\b${search}`, 'i');
const filteredResults = queryResults.filter(s => re.test(s));

filteredResults // ["Git", "My Git Example", "Gitosis"]