Shoeb Athar
Posts: 0
Joined: Wed Aug 12, 2015 7:56 am

Query a an exact string while ignoring case

I have a column File_Content in my DB having lot of text in string format.
keyword is input value to be searched.
I need to search specific words if the exact string matches.

I am using QUERY service with following code in JS:

1) return '{"File_Content":{"$regex":"^"'+keyword+'"$", "$options":"i"}}';
Not Working :(

2) return '{"File_Content": {"$regex": "^' + keyword + '$", "$options":"i"}}'
Not Working :(

3) return "{'File_Content':{'$regex':'(?i).^"+ keyword +"$'.'}}";
Not Working :(

If i remove ^ and $ every query works but not match exact string.

Please provide me solution to match exact string
Thanks in advance

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Query a an exact string while ignoring case

Hello Shoeb,

You shouldn't use "^" and "$" at the same time. Please use only one of them.

Return to “Issues”