java - Ignore symbols on String.contain -


I am working as a search in my app and need to check whether my text includes that word The user who has entered has entered.

Currently my code is:

  if (textToCheck.toLowerCase (.) Contains (input.toLowerCase ())) {   

That works perfectly well. But, I want to search my search wisely, and only search for letters, for example if the app has other symbols (instead of as), then the app will ignore them:

Example: If this is my text and this is my input, then I need a match.

textToCheck = "will not work with search, comma, bracket, or any other symbol"

input = "work with comma brackets"

You

  / ** * @surf * @seer Http://stackoverflow.com/questions/15190656/easy-way-to-remove-utf-8-accents-from-a-string * / Private static string strip accents (strings) {string s1 = normalized.Normalize (s) , Normalizer.form.nfd); S1 = s1.replaceAll ("[\\ p {InCombiningDiacriticalMarks}]", ""); Return s1; } Private Static String only alphabets (string string) {Return strip accents (string) // does not remove any letters or places. All ("[^ A-Za-z \\ s]", "") // empty in Converts the location chain into a single spaces .replaceAll ("\\ s {2,}", "") // gets the lower case. } Public static Boolean search (string text tone, string input) {string generalized hole = only alphabet (texttobierzor); String Normalized input = only; Generalized vowel canens (normalized input); }  

If you are not going to receive frequently asked characters, you can skip strip assignments method.

The method only elfbat reduces several locations to only one place, thus, if the user writes something like "comma, brackets", then it will be the same as it is written "coma brackets" < / P>


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -