欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

又一不错的应用-正则来查找替换字符串

程序员文章站 2022-04-16 15:40:05
以下这段代码截取自某一网页源码: onclick="mm_openbrwindow('../photo/nlife/sfc/pages/o'connors_jpg.htm'...
以下这段代码截取自某一网页源码:
onclick="mm_openbrwindow('../photo/nlife/sfc/pages/o'connors_jpg.htm','rd','width=456,height=368')"
onclick="mm_openbrwindow('../photo/nlife/sfc/pages/trad'r sam_jpg.htm','rd','width=456,height=368')"
onclick="mm_openbrwindow('../photo/nlife/sea/pages/mondo's beach pub_jpg.htm','rd','width=456,height=368')"
onclick="mm_openbrwindow('../photo/nlife/tam/pages/mirage (moet's) _jpg.htm','rd','width=456,height=368')"
onclick="mm_openbrwindow('../photo/nlife/tem/pages/macayo's - n central_jpg.htm','rd','width=456,height=368')">
onclick="mm_openbrwindow('../photo/nlife/tem/pages/rt o'sullivans_jpg.htm','rd','width=456,height=368')"
onclick="mm_openbrwindow('../photo/nlife/nyc/pages/pat o'hurley's bar & grill_jpg.htm','rd','width=456,height=368')"
这里需要把链接中的'批量替换成'\,注意链接中有空格、特殊字符(横杠、括号、&等),有的地方'还出现不止一次。替换过程中还不能把其他地方的'和链接中的其他内容替换掉,我想到用dw的正则替换,请问这样的正则表达式要怎么写呢?

[ctrl+a 全选 注:如需引入外部js需刷新才能执行]/textarea>