Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建和活动,我需要在文本区域中验证正确的输入类型。我想避免任何 XSS 或 Mysql 注入。
我想接受 [az] [AZ] [0-9] [.] [,] 和空格。
我现在唯一得到的是:
Pattern pattern_ = Pattern.compile("^[:alpha:]+(?:(?:\\s+|-)[:alpha:]+)*$");
你将如何实现它?
为什么不这样做:
Pattern pattern_ = Pattern.compile("^[a-zA-Z0-9\.,\s]+$");