At the moment I have the following $scope.user.username.replace(/[\\s]/g, '');
This removes and special characters and spaces, I need to add in the ability to prevent numbers and special characters too but I can't quite grasp how Regex works.
Would someone be able to help me out?
只需在字符类中添加要删除的字符:
replace(/[\s.;,?%0-9]/, '')
You should just be able to use not
in the matching group and remove everything that isn't a letter:
/[^a-zA-Z]/g
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.