又一不错的应用-正则来查找替换字符串
程序员文章站
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的正则替换,请问这样的正则表达式要怎么写呢?
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的正则替换,请问这样的正则表达式要怎么写呢?
上一篇: 一个非常不错的一个正则练习JS版
下一篇: 桑果酒的功效与作用,这些你知道吗?