Reputation: 84
I want to search in my data. I'm using regular expression with IsMatch() function.
I have a class:
public class MyClass
{
public string Name { get; set; }
public string Address { get; set; }
}
I want to search in my data by Name Or Address, and Name or Address Like input
With input FuzzySearch is: a%b
or a%b%c
or japanese characters (ex:区%水
).
In main function I have a list: List<MyClass> data
and using regular expression with IsMatch() function as below:
Regex regex = new Regex(FuzzySearch, RegexOptions.IgnoreCase);
var allInfoList1 = allInfoList.Where(x => regex.IsMatch(x.Name) ||
regex.IsMatch(x.Address)).ToList();
Sometime result is true, but sometime result is wrong( with case input is japanese characters)
(Is the regular expression not support unicode?) Are there any other solutions?
Upvotes: 1
Views: 208
Reputation: 5369
Rather than implementing your own document search engine, I would suggest considering tools like Apache Lucene or Apache Solr. I do not know your specific use case, and perhaps my suggestion is an overkill, but I would give it a thought.
Hope I helped!
Upvotes: 1