标签 正则 下的文章

Regular Expression

马上收藏!史上最全正则表达式合集
密码强度的正则表达式(JavaScript)总结
身份证号码的正则表达式及验证详解(JavaScript,Regex)
https://m.w3cschool.cn/regex_rmjc/
https://www.w3cschool.cn/regex_rmjc/
正则表达式30分钟入门教程

过滤文章中多余的------
//正则 匹配多余的
var arr = ['----------------------------------------------------------------------------------------------------'];//100个
var arr1 = ['--------------------------------------------------'];//50个
var arr2 = ['-------------------------'];//25个-
var arr3 = ['-----','----------'];//5,10个-
//多次匹配和一次匹配的结果不同
//var arr3 = ['-----','------','-------','--------','---------','----------'];//5,6,7,8,9,10个
var res = it.internalNotic.replace(new RegExp(arr.join('|'),'img'),'-');
var res1 = res.replace(new RegExp(arr1.join('|'),'img'),'-');
var res2 = res1.replace(new RegExp(arr2.join('|'),'img'),'-');
var res3 = res2.replace(new RegExp(arr3.join('|'),'img'),'-');
console.log(res);
console.log(res1);
console.log(res2);
console.log(res3);


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title></title>
  <link rel="stylesheet" href="">
  <script src="jquery.js"></script>
</head>
<body>
  <table class="list" style="width:100%;">
        <tbody><tr>
          <th style="width: 20%; min-width: 168px; max-width: 192px;">审核用户</th>
          <th style="width: 20%; min-width: 120px; max-width: 144px;">审核结果</th>
          <th style="width: 20%; min-width: 120px; max-width: 144px;">审核日期</th>
          <th style="width:60%">相关说明</th>
        </tr>
        </tbody><tbody oddclass="list-odd" evenclass="list-even" hoverclass="list-hover" class="shsjvalidation">
          
            <tr>
              <td style="min-width: 168px; max-width: 192px;">
                葛大爷
              </td>
              <td style="min-width: 120px; max-width: 144px;">
                审核中
              </td>
              <td style="min-width: 120px; max-width: 144px;">2017-06-02</td>
              <td style="white-space: inherit; overflow: inherit; text-overflow: inherit;">
                
              </td>
            </tr>
          
            <tr>
              <td style="min-width: 168px; max-width: 192px;">
                a的上级
              </td>
              <td style="min-width: 120px; max-width: 144px;">
                同意
              </td>
              <td style="min-width: 120px; max-width: 144px;">2017-06-02</td>
              <td style="white-space: inherit; overflow: inherit; text-overflow: inherit;">
                
              </td>
            </tr>
          
        </tbody>
      </table>
<script>
    str="审核中";
    var reg = /审核中/ig;
    var shstr = $(".shsjvalidation tr td:nth-child(2)").text();
    console.log(shstr);
    var newshsjstr = $(".shsjvalidation tr td:nth-child(3)").text();
    console.log(newshsjstr);
    $('.shsjvalidation tr td:nth-child(2)').each(function(index){
    // console.log("这是第"+index+"个: "+$(this).html());
    console.log($(this).html());
    if($(this).html().match(str)){
      // alert("ok");
      $(this).next("td").css("background-color","yellow");
      // $('.shsjvalidation tr td:nth-child(2)').css("background-color","yellow");
    }
    })
    
  </script>
</body>
</html>

自行添加jq文件


var srcreg=/^.*\.(jpeg|jpg|gif|png|bmp)$/i;
var srcpic=data[i].gdtpwj.match(srcreg);//判断是否为图片后缀
console.log(srcpic);
if(srcpic){
$('#head-img').html('<img src="'+ data[i].gdtpwj +'" />');
}
else{
return false;
}