I have a regex search in my code for getting names in my db by the given string. The problem I'm having is that if I have a name "Jim" and a name "Jimmy", I always get the "Jimmy" for some reason.
let regexp = new RegExp(userName, "i");
let name = await names.findOne({ name: regexp });
So when I type in "Jimmy" I get Jimmy, "Jimm" I get Jimmy, all good, but when I try to find "Jim" I get Jimmy, so there's no way for me to get Jim.
Also I can't find names if they have ( or ) ? Ex: Tom (Thomas), and i search exactly "Tom (Thomas)" it doesn't find it at all, but that might be a Mongoose problem.