简体   繁体   中英

Replace a text with regular expression in notepad++

I want to replace all the url's which are starting with something like www.sitename.com/xxx/xxx.html and the last part of the string is different on each url. Is there any formula in notepad++ which replace the whole string with "#" or any custom character ?

Bring on the Find and Replace dialog, select Replace ( Ctrl+H )

Search mode: Regular expression

Find what: www\\.sitename\\.com/\\w+/\\w+\\.html

Replace with: # (or anything you wish)

This will replace URLs of the type you've provided in question ( www.sitename.com/xxx/xxx.html )

Press Ctrl+H to bring up the replace window. Enter this in the Find what: section:

www\.sitename\.com(/\w+)*\.?\w*

and anything you want (#) in the Replace with: . Make sure that Search Mode is on Regulare Expression and the hit the Find next , Replace or Replace All

This will replace all the URLs beginning with www.sitename.com and ending with and extension (.html, .jpg, ...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM