我需要只允许使用拉丁字符,数字和所有其他符号的正则表达式(但不能使用空格)
谢谢!
更新:
private boolean loginPassHasCorrectSymbols(String input){
if (input.matches("[A-Za-z0-9\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\>\=\?\@\[\]\{\}\\\^\_\`\~]+$")){
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud) 我的android应用程序中有一个Edittext.我想不允许用户输入第一个空格字符.但是在输入其他字符后,用户也可以输入空格 ..我用过
<EditText
android:id="@+id/editText1_in_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="text"
android:digits="_,qwertzuiopasdfghjklyxcvbnm,QWERTYUIOPASDFGHJKLZXCVBNM,0123456789">
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,用户无法输入空间.
我也使用了Text Watcher,但我不需要在输入文本时允许用户为android:digits工作.