Jquery 源码中用到的正则
打开http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js
看了一眼,jquery用的正则出乎意料的少呀。
?
?
// A simple way to check for HTML strings or ID strings// (both of which we optimize for)quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,// Is it a simple selectorisSimple = /^.[^:#\[\.,]*$/,// Check if a string has a non-whitespace character in itrnotwhite = /\S/,// Used for trimming whitespacertrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,// Match a standalone tagrsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
后面还用到了一些比较简短的正则