We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Can I ignore specific characters in a search strng?

Hello, I am working on a form where a user will select a caliber from a list of options. Calibers will begin with a "." but a lot of the time users forget that. So if they want to search for .357, they may type 357, like wise when selecting a specific size 9mm for instance there is no period, (but I would like to again be able to ignore when appropriate)

Is there any way to make the autocomplete control ignore characters, and still look for non literal but inferred strings? eg: .357 works because it's correct formatting, but 357 also works and assumes the leading "."


2 Replies

JK Jesse Knott July 29, 2019 05:56 AM UTC

In hind sight (sorry I couldn't find a way to edit my original poat) Could a regex member field be applied? allowing the user to specify a regex over the autocomplete source items? I can imagine a few situations where that could be handy..

Thanks again!

MK Muneesh Kumar G Syncfusion Team July 29, 2019 12:28 PM UTC

Hi Jesse, 
Greetings from Syncfusion.  
We have checked the reported scenario and achieved using SuggestionMode as Custom Search. Through Custom Search we can achieve our logic and set the text only by returning it to true. Please have the sample from the below link, 
Code Snippet: 
public bool ContainingSpaceFilter(string search, object item)
            string text = item.ToString().ToLower();
            if (item != null)
                if (!search.Contains("."))
                    search = search.Insert(0, ".");

                if (text.StartsWith(search.ToLower()))
                    return true;

            return false;
Please check with the sample and if the mentioned scenario differs from the sample please provide a video representation for the same which will be helpful for us to analyze further and provide an appropriate solution. 
Muneesh Kumar G.  

Live Chat Icon For mobile
Up arrow icon