Another good application-Regular Expression to find replacement strings

Source: Internet
Author: User

The following code is taken from the source code of a webpage:
OnClick = "MM_openBrWindow ('../photo/nlife/sfc/pages/o'connors_jpg.htm', 'rd', 'width = 456, height = 100 ')"
OnClick = "MM_openBrWindow ('../photo/nlife/sfc/pages/Trad 'r sam_jpg.htm', 'rd', 'width = 456, height = 100 ')"
OnClick = "MM_openBrWindow ('../photo/nlife/sea/pages/Mondo's Beach pub_jpg.htm', 'rd', 'width = 456, height = 100 ')"
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 = 100 ')"
OnClick = "MM_openBrWindow ('.. /photo/nlife/nyc/pages/Pat O 'Hurley's Bar & grill_jpg.htm', 'RD ', 'width = 456, height = 368 ')"
Here, you need to replace 'batch with '\ In the link. Note that there are spaces, special characters (horizontal bars, Parentheses, and &) in the Link. In some cases,' appears more than once. During the replacement process, you cannot replace 'from other places or other content in the link. I want to replace it with a DW regular expression. How can I write such a regular expression? <Textarea id = "txtSrc" rows = "15" cols = "80"> <br/> onClick = "MM_openBrWindow ('.. /photo/nlife/sfc/pages/o'connors_jpg.htm', 'rd', 'width = 456, height = 368 ') "<br/> onClick =" MM_openBrWindow ('.. /photo/nlife/sfc/pages/Trad 'r sam_jpg.htm', 'rd', 'width = 456, height = 368 ') "<br/> onClick =" MM_openBrWindow ('.. /photo/nlife/sea/pages/Mondo's Beach Pub_jpg.htm ', 'RD', 'width = 456, height = 368 ') "<br/> onClick =" MM_openBrWindow ('.. /photo/nlife/tam/pages/Mirage (Moet's) _jpg.htm ', 'RD', 'width = 456, height = 368 ') "<br/> onClick =" MM_openBrWindow ('.. /photo/nlife/tem/pages/Macayo's-N Central_jpg.htm ', 'RD', 'width = 456, height = 368 ') "> <br/> onClick =" MM_openBrWindow ('.. /photo/nlife/tem/pages/RT o'sullivans_jpg.htm', 'RD ', 'width = 456, height = 368') "<br/> onClick =" MM_openBrWindow ('.. /photo/nlife/nyc/pages/Pat O 'Hurley's Bar & grill_jpg.htm', 'RD ', 'width = 456, height = 368 ') "</p> <input type =" text "id =" txregulatory "value =" (\ w) \ '(\ w) "> <input type =" text "id =" txtTo "value =" $1 \ '$2 "> <input type =" button "onclick =" txtDes. value = txtSrc. value. replace (new RegExp (txreg. value, 'ig '), txtTo. value); "value =" replace "> <textarea id =" txtDes "rows =" 15 "cols =" 80 ">
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.