注:前端常用正则表达式,如大陆手机号,强密码等。另附了正则来源,有需要的话看源数据,还有更多
表单验证
手机号
// from https://github.com/VincentSit/ChinaMobilePhoneNumberRegex
export const ruleIsMobile = (mobile: string) =>
/^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[235-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0-35-9]\d{2}|66\d{2})\d{6}$/.test(
mobile
);
强密码
/**
* from https://stackoverflow.com/questions/5142103/regex-to-validate-password-strength
* 8 characters length
* 2 letters in Upper Case
* 1 Special Character (!@#$&*)
* 2 numerals (0-9)
* 3 letters in Lower Case
*/
export const ruleIsStrongPasswd = (passwd: string) =>
/^(?=.*[A-Z].*[A-Z])(?=.*[!@#$&*])(?=.*[0-9].*[0-9])(?=.*[a-z].*[a-z].*[a-z]).{8}$/.test(
passwd
);
删除远程已经没有的本地分支
#拉取远程到本地,并更新本地和远程的对应关系
$ git fetch -p
# 然后再执行 删除本地分支(远程已经没有的对应的分支)
$ git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d