string formatting - How to ignore spaces between text editview Android -
i trying ignore spaces in editview between text, not quite sure how can go doing this. know can use trim feature ignore spaces before , after full text how ignore space between strings if there any;
string mytextedited mytext.gettext().tostring().trim();
for example, if have / user types in this;
allan bob 3523 jko ny1 u90
i want ingore spaces when read in if statement or put in variable example;
string name = "allanbob"
for example, ignore upper , lower cases doing this;
if (mytext.gettext().tostring().trim().equalsignorecase(userinput)) { // } else { // }
what add feature in here ignores spaces before, between , after text e.g. instead of;
myname henry . (space until here)
it should read mynameishenry user still appears have written it.
please let me know if question not clear, try explaining better
edited:
is possible ignore spaces in string have inside if statement. example;
if (mytext.gettext().tostring().trim().equalsignorecase("henry 0887")) { // } else { // }
but if user types in henry0887, if statement not validate because added space inside validation text , therefoe looking space in text, possible on come this, if have space inside validation ignores it.
did try this:
string mystring = myedittext.gettext().tostring(); mystring = mystring .replace(" ", "");
hope helps
edit:
if (mytext.gettext().tostring().replace(" ", "").equalsignorecase(userinput) || mytext.gettext().tostring().equalsignorecase(userinput)) {...
Comments
Post a Comment