admin 发表于 2016-10-19 17:47:03

知道这20个正则表达式,能让你少写1,000行代码

<p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">正则表达式,一个十分古老而又强大的文本处理工具,仅仅用一段非常简短的表达式语句,便能够快速实现一个非常复杂的业务逻辑。熟练地掌握正则表达式的话,能够使你的开发效率得到极大的提升。</p><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">正则表达式经常被用于字段或任意字符串的校验,如下面这段校验基本日期格式的JavaScript代码:</p><pre class="hljs scala" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="scala" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;"><span class="hljs-keyword" style="color: rgb(133, 153, 0);">var</span> reg = /^(\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>})(-|\\/)(\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>})\\<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>(\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>})$/;
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">var</span> r = fieldValue.<span class="hljs-keyword" style="color: rgb(133, 153, 0);">match</span>(reg);            
<span class="hljs-keyword" style="color: rgb(133, 153, 0);">if</span>(r==<span class="hljs-literal">null</span>)alert(<span class="hljs-symbol" style="color: rgb(203, 75, 22);">'Date</span> format error!');</code></pre><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">下面是<strong>技匠</strong>整理的,在前端开发中经常使用到的<strong>20</strong>个正则表达式。</p><hr style="margin-bottom: 20px; border-right-width: 0px; border-left-width: 0px; border-top-style: solid; border-top-color: rgb(217, 217, 217); border-bottom-style: solid; border-bottom-color: white; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>1 . 校验密码强度</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">密码的强度必须是包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间。</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^(?=.*\\d)(?=.*)(?=.*).{<span class="hljs-number" style="color: rgb(42, 161, 152);">8</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">10</span>}$</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>2. 校验中文</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">字符串仅能是中文。</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>u4e00-<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>u9fa5<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span><span class="hljs-special" style="color: rgb(203, 75, 22);">{</span>0,<span class="hljs-special" style="color: rgb(203, 75, 22);">}</span><span class="hljs-formula" style="color: rgb(42, 161, 152); background: rgb(238, 232, 213);">$</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>3. 由数字、26个英文字母或下划线组成的字符串</strong></h4><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>w+<span class="hljs-formula" style="color: rgb(42, 161, 152); background: rgb(238, 232, 213);">$</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>4. 校验E-Mail 地址</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">同密码一样,下面是E-mail地址合规性的正则检查语句。</p><pre class="hljs markdown" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="markdown" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">\\w!#$%&amp;'*+/=?^_`{|}~-</span>]+(?:\\.[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">\\w!#$%&amp;'*+/=?^_`{|}~-</span>]+)<span class="hljs-emphasis">*@(?:[\\w](?:[\\w-]*</span>[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">\\w</span>])?\\.)+[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">\\w</span>](<span class="hljs-link_url" style="color: rgb(42, 161, 152);">?:[\\w-]*[\\w]</span>)?</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>5. 校验身份证号码</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">下面是身份证号码的正则校验。15 或 18位。</p><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">15位:</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^[<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>}((<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>\\d)|(<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>]))(([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>]\\d)|<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>])\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}$</code></pre><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">18位:</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^[<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}((<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>\\d)|(<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>]))(([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>]\\d)|<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>])\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]|X)$</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>6. 校验日期</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">“yyyy-mm-dd“ 格式的日期校验,已考虑平闰年。</p><pre class="hljs markdown" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="markdown" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^(?:(?!0000)[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-9</span>]{4}-(?:(?:0[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">1-9</span>]|1[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-2</span>])-(?:0[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">1-9</span>]|1[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-9</span>]|2[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-8</span>])|(?:0[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">13-9</span>]|1[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-2</span>])-(?:29|30)|(?:0[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">13578</span>]|1[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">02</span>])-31)|(?:[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-9</span>]{2}(?:0[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">48</span>]|[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">2468</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">048</span>]|[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">13579</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">26</span>])|(?:0[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">48</span>]|[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">2468</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">048</span>]|[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">13579</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">26</span>])00)-02-29)$</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>7. 校验金额</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">金额校验,精确到2位小数。</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]+(.[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]{<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>})?$</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>8. 校验手机号</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">下面是国内 13、15、18开头的手机号正则表达式。(可根据目前国内收集号扩展前两位开头号码)</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^(<span class="hljs-number" style="color: rgb(42, 161, 152);">13</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">14</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">15</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">6</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">8</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">18</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">6</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">8</span>|<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>])\\d{<span class="hljs-number" style="color: rgb(42, 161, 152);">8</span>}$</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>9. 判断IE的版本</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">IE目前还没被完全取代,很多页面还是需要做版本兼容,下面是IE版本检查的表达式。</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^.*MSIE [<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">8</span>](?:\\.[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]+)?(?!.*Trident\\/[<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]\\<span class="hljs-number" style="color: rgb(42, 161, 152);">.0</span>).*$</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>10. 校验IP-v4地址</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">IP4 正则语句。</p><pre class="hljs markdown" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="markdown" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">\\b(?:(?:25[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-5</span>]|2[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-4</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">0-9</span>]|[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">01</span>]?[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-9</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">0-9</span>]?)\\.){3}(?:25[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-5</span>]|2[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-4</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">0-9</span>]|[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">01</span>]?[<span class="hljs-link_label" style="color: rgb(108, 113, 196);">0-9</span>][<span class="hljs-link_reference" style="color: rgb(181, 137, 0);">0-9</span>]?)\\b</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>11. 校验IP-v6地址</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">IP6 正则语句。</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">(([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>}:|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">6</span>}:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>}(:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>}|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}(:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}(:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>}(:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>}|[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:((:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">6</span>})|:((:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">7</span>}|:)|fe80:(:[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}%[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-zA-Z]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,}|::(ffff(:<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}((<span class="hljs-number" style="color: rgb(42, 161, 152);">25</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>]|(<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>{<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>])\\.){<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}(<span class="hljs-number" style="color: rgb(42, 161, 152);">25</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>]|(<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>{<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>])|([<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>a-fA-F]{<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:){<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>}:((<span class="hljs-number" style="color: rgb(42, 161, 152);">25</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>]|(<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>{<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>])\\.){<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>}(<span class="hljs-number" style="color: rgb(42, 161, 152);">25</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">5</span>]|(<span class="hljs-number" style="color: rgb(42, 161, 152);">2</span>[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">4</span>]|<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>{<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]){<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>,<span class="hljs-number" style="color: rgb(42, 161, 152);">1</span>}[<span class="hljs-number" style="color: rgb(42, 161, 152);">0</span>-<span class="hljs-number" style="color: rgb(42, 161, 152);">9</span>]))</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>12. 检查URL的前缀</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">应用开发中很多时候需要区分请求是HTTPS还是HTTP,通过下面的表达式可以取出一个url的前缀然后再逻辑判断。</p><pre class="hljs scala" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="scala" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;"><span class="hljs-keyword" style="color: rgb(133, 153, 0);">if</span> (!s.<span class="hljs-keyword" style="color: rgb(133, 153, 0);">match</span>(/^+:\\/\\<span class="hljs-comment" style="color: rgb(147, 161, 161);">//))</span>
{
    s = <span class="hljs-symbol" style="color: rgb(203, 75, 22);">'http</span>:<span class="hljs-comment" style="color: rgb(147, 161, 161);">//' + s;</span>
}</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>13. 提取URL链接</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">下面的这个表达式可以筛选出一段文本中的URL。</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^(f|ht)<span class="hljs-special" style="color: rgb(203, 75, 22);">{</span>1<span class="hljs-special" style="color: rgb(203, 75, 22);">}</span>(tp|tps):<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/(<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>w-<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>.)+<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>w-<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+(<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>w- ./?<span class="hljs-comment" style="color: rgb(147, 161, 161);">%&amp;=]*)?</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>14. 文件路径及扩展名校验</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">验证windows下文件路径和扩展名(下面的例子中为.txt文件)</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^(<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>a-zA-Z<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>:|<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>)<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>(<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span><span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>)*<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/:*?"&lt;&gt;|<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>.txt(l)?<span class="hljs-formula" style="color: rgb(42, 161, 152); background: rgb(238, 232, 213);">$</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>15. 提取Color Hex Codes</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">有时需要抽取网页中的颜色代码,可以使用下面的表达式。</p><pre class="hljs cpp" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="cpp" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^<span class="hljs-preprocessor" style="color: rgb(203, 75, 22);">#({<span class="hljs-number" style="color: rgb(42, 161, 152);">6</span>}|{<span class="hljs-number" style="color: rgb(42, 161, 152);">3</span>})$</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>16. 提取网页图片</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">假若你想提取网页中所有图片信息,可以利用下面的表达式。</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;"><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>&lt; *<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>img<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span><span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>&gt;<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>*<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>src<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span> *= *<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>"<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>'<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span><span class="hljs-special" style="color: rgb(203, 75, 22);">{</span>0,1<span class="hljs-special" style="color: rgb(203, 75, 22);">}</span>(<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>"<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>'<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span> &gt;<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>*)</code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>17. 提取页面超链接</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">提取html中的超链接。</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">(&lt;a<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*(?!.*<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>brel=)<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^&gt;<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>*)(href="https?:<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/)((?!(?:(?:www<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>.)?'.implode('|(?:www<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>.)?', <span class="hljs-formula" style="color: rgb(42, 161, 152); background: rgb(238, 232, 213);">$follow_list).'))<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^"<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+)"((?!.*<span class="hljs-command">\\</span>brel=)<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^&gt;<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>*)(?:<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>^&gt;<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>*)&gt;</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>18. 查找CSS属性</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">通过下面的表达式,可以搜索到相匹配的CSS属性。</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">^<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>a-zA-Z<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>-<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>:<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span><span class="hljs-special" style="color: rgb(203, 75, 22);">{</span>1<span class="hljs-special" style="color: rgb(203, 75, 22);">}</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>a-zA-Z0-9<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s.<span class="hljs-special" style="color: rgb(203, 75, 22);">#</span><span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span>;<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span><span class="hljs-special" style="color: rgb(203, 75, 22);">{</span>1<span class="hljs-special" style="color: rgb(203, 75, 22);">}</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>19. 抽取注释</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">如果你需要移除HMTL中的注释,可以使用如下的表达式。</p><pre class="hljs xml" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="xml" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;"><span class="hljs-comment" style="color: rgb(147, 161, 161);">&lt;!--(.*?)--&gt;</span></code></pre><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;"><strong>20. 匹配HTML标签</strong></h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">通过下面的表达式可以匹配出HTML中的标签属性。</p><pre class="hljs tex" style="padding: 9.5px; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 13px; color: rgb(101, 123, 131); border-radius: 4px; margin-bottom: 20px; line-height: 20px; word-break: break-all; word-wrap: normal; border: 1px solid rgba(0, 0, 0, 0.14902); overflow: auto; background: rgb(253, 246, 227);"><code class="tex" style="font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border-radius: 3px; border: none; background-color: transparent;">&lt;<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/?<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>w+((<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s+<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>w+(<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*=<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*(?:".*?"|'.*?'|<span class="hljs-special" style="color: rgb(203, 75, 22);">[</span><span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>^'"&gt;<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s<span class="hljs-special" style="color: rgb(203, 75, 22);">]</span>+))?)+<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*|<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>s*)<span class="hljs-command" style="color: rgb(42, 161, 152);">\\</span>/?&gt;</code></pre><hr style="margin-bottom: 20px; border-right-width: 0px; border-left-width: 0px; border-top-style: solid; border-top-color: rgb(217, 217, 217); border-bottom-style: solid; border-bottom-color: white; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;">正则表达式的相关语法</h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">下面是我找到的一张非常不错的正则表达式 Cheat Sheet,可以用来快速查找相关语法。</p><div class="image-package imagebubble" widget="ImageBubble" style="margin-right: auto; margin-bottom: 20px; margin-left: auto; text-align: center; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><img src="http://upload-images.jianshu.io/upload_images/1399853-1b08244a4d375624.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" data-original-src="http://upload-images.jianshu.io/upload_images/1399853-1b08244a4d375624.jpg?imageMogr2/auto-orient/strip%7CimageView2/2" class="imagebubble-image" style="max-width: 100%; height: auto; vertical-align: middle; border: 0px; cursor: -webkit-zoom-in; transition: all 0.25s ease-in-out;"><br></div><hr style="margin-bottom: 20px; border-right-width: 0px; border-left-width: 0px; border-top-style: solid; border-top-color: rgb(217, 217, 217); border-bottom-style: solid; border-bottom-color: white; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;">学习正则表达式</h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">我在网上看到了一篇相当不错的正则表达式<a href="https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx" target="_blank" style="color: rgb(64, 148, 199); text-decoration: none;">快速学习指南</a>,有兴趣继续深入学习的同学可以参考。</p><div class="image-package imagebubble" widget="ImageBubble" style="margin-right: auto; margin-bottom: 20px; margin-left: auto; text-align: center; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><img src="http://upload-images.jianshu.io/upload_images/1399853-017f7201958ae676.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" data-original-src="http://upload-images.jianshu.io/upload_images/1399853-017f7201958ae676.png?imageMogr2/auto-orient/strip%7CimageView2/2" class="imagebubble-image" style="max-width: 100%; height: auto; vertical-align: middle; border: 0px; cursor: -webkit-zoom-in; transition: all 0.25s ease-in-out;"><br></div><hr style="margin-bottom: 20px; border-right-width: 0px; border-left-width: 0px; border-top-style: solid; border-top-color: rgb(217, 217, 217); border-bottom-style: solid; border-bottom-color: white; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><h4 style="font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; line-height: 1.8; color: rgb(47, 47, 47); text-rendering: optimizeLegibility; font-size: 20px;">正则表达式在线测试工具</h4><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><a href="https://regex101.com/#javascript" target="_blank" style="color: rgb(64, 148, 199); text-decoration: none;">regex101</a>是一个非常不错的正则表达式在线测试工具,你可以直接在线测试你的正则表达式哦。<br></p><div class="image-package imagebubble" widget="ImageBubble" style="margin-right: auto; margin-bottom: 20px; margin-left: auto; text-align: center; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><img src="http://upload-images.jianshu.io/upload_images/1399853-2c13bde71d91694c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" data-original-src="http://upload-images.jianshu.io/upload_images/1399853-2c13bde71d91694c.png?imageMogr2/auto-orient/strip%7CimageView2/2" class="imagebubble-image" style="max-width: 100%; height: auto; vertical-align: middle; border: 0px; cursor: -webkit-zoom-in; transition: all 0.25s ease-in-out;"><br></div><hr style="margin-bottom: 20px; border-right-width: 0px; border-left-width: 0px; border-top-style: solid; border-top-color: rgb(217, 217, 217); border-bottom-style: solid; border-bottom-color: white; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;"><p style="margin-bottom: 25px; text-align: justify; word-break: break-word; color: rgb(47, 47, 47); font-family: -apple-system, 'Helvetica Neue', Arial, 'PingFang SC', 'lucida grande', 'lucida sans unicode', lucida, helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif; font-size: 16px; line-height: 27.2px;">另外,我也网上找到几本不错的正则表达式方面的教程和书籍,并将它们分享到了<a href="http://www.jianshu.com/p/e7bb97218946/comments/jijiangshe.com" target="_blank" style="color: rgb(64, 148, 199); text-decoration: none;">技匠社jijiangshe.com</a>,如果你有兴趣学习欢迎访问获取。^_^</p><p></p>
页: [1]
查看完整版本: 知道这20个正则表达式,能让你少写1,000行代码