文件path处理

  1. // replace /./ => /
  2. pattern = /\/\.\//;
  3. while (pattern.test(r)) {
  4. r = r.replace(pattern, '/');
  5. }
  6. // replace ^./ => nothing
  7. r = r.replace(/^\.\//g, '');
  8. // replace /aa/../ => / (BUT IGNORE /../../)
  9. pattern = /\/(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//;
  10. while (pattern.test(r)) {
  11. r = r.replace(pattern, '/');
  12. }
  13. // replace ^aa/../ => nothing (BUT IGNORE ../../)
  14. r = r.replace(/^(([^\/])|([^\/][^\/\.])|([^\/\.][^\/])|([^\/][^\/][^\/]+))\/\.\.\//, '');

邮箱

  1. /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/

分号分隔符的邮箱字符串

  1. /^((([a-z0-9.-]+)@([\da-z.-]+)\.([a-z.]{2,6};))*(([a-z0-9.-]+)@([\da-z.-]+)\.([a-z.]{2,6})))$/