正则(自编留平时自用)

在文档里查找一个最小(无嵌套)标签:  <([^<>]+)>[^<>]*<\/\1>


保留网页时:

(1)css

 查找css引用文本 :href="[^<>]*/([^/<>]*).css

替换里面的路径部分:href="新的路径/$1.css


同理:更改 js, 图片引用路径等


(2)js: 

引用:src="[^<>]*/([^/<>]*).js

替换:src="新的路径/$1.js


(3)图片: 

引用:

url\(("?)[^<>()]*/([^/<>()]*"?)\)

替换:url($1新的路径/$2)



日常:

(1)日期:^\d{4}-(1[012]|0?[1-9])-(0?[1-9]|[12]\d|3[01])$

          格式: 2015-09-02 或 2015-9-2  ,  月份<=12,日最大31


不解释,结合反向引用自己体会:

var englishPara=' ******if someone loves a flower, of which just one single blossom grows in all the millions and millions of stars, it is enough to make him happy just to look at the stars. he can say to himself, "somewhere, my flower is there…" but if the sheep eats the flower, in one moment all his stars will be darkened… and you think that is not important! ';
var ptn=/(\s*[^a-zA-Z\s]+\s*)([a-zA-Z])/g;
var res=englishPara.replace(ptn,function(m,n,o){return n+o.toUpperCase()});
   //首单词处理
   res=res.replace(/^([^a-zA-Z\s]*)([a-zA-Z])/,function(m,n,o){return n+o.toUpperCase()})


废弃css样式处理:

(border:1px[^;]*;)

/*$1*/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值