Skip to content

Instantly share code, notes, and snippets.

@kindy61
Created September 1, 2011 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kindy61/1185390 to your computer and use it in GitHub Desktop.
Save kindy61/1185390 to your computer and use it in GitHub Desktop.
whitespace regex from www.jb51.net/article/25710.htm
var trimInfo =
{ basic: / /
// vb中的简单空白字符过滤
, classic: /\s/
// 传统的js空白字符过滤
, ecmascript5: /[\s\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
// ECMAScript 5中对/s的补充定义
, ex: /[\s\xA0\u2028\u2029]/
// 印象中是和js中的标识符或者字符串有关,忘了从哪来的了XD
, control: /[\x00-\x1F\x7F-\x9F]/
// 补充了控制字符的简单过滤
, dotNet: /[\s\xA0\u2000-\u200B\u3000\uFEFF]/
// .NET平台的默认实现
, unicode: /[\s\x85\xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
// 过滤Unicode标准中定义的空白字符
, complex: /[\x00-\x20\x7F-\xA0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000\uFEFF]/
// 复合的过滤,是以上几种的并集
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment