Android keybord should not accept non-text characters such as space, enter, return etc while entering input string.
I tried with few, as shown below -
this is for the regex.
- the \b is to find word boundary.
- the positive look ahead (?=\w) is here to avoid spaces.
onChange = { if (it.contains(Regex("(?=\\w)"))) onInput(it) }
but in my case first character space is not accepting but in second character onwards it is accepting. I'm new this regular expression, can any one help me?
For space -> (?=\w) value for ignore then what is the value for enter and return if any one knows please post here your answer ?
Update 1:
In EditText, If I enter non-string char at very first character of the input below code is working correctly:
onChange = { if (it.contains(Regex("[0123456789qwertzuiopasdfghjklyxcvbnm]"))) onInput(it) }
but If I enter string char at first place and 2nd char position onwards non-text character is accepting, so my question is how to apply same condtion for all characters of the input string ?
Thanks!