读书人

Jquery 源码顶用到的正则

发布时间: 2012-10-09 10:21:45 作者: rapoo

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>)?$/,

后面还用到了一些比较简短的正则

读书人网 >Web前端

热点推荐