简体   繁体   中英

Sublime Text Regex Replace and Append

Can someone please help me with a regular expression.

I'm having trouble with even the start as I'm a regex absolute beginner and the tutorials aren't really helping as I'm not understanding it.

I've got a large amount of files with things like 'products.htmlcar' or 'products.htmlcar_paper' or 'products.htmlhome-decorative_air_freshener'

I'm trying to remove all instances in all my files of the words "'products.html" and replace them with just the text at the end of it and append html to it before the ending " ' " for example 'products.htmlcar' becomes 'car.html' or 'products.htmlhome-decorative_air_freshener' becomes 'home-decorative_air_freshener.html'

I have tried to do a few of the things I checked out like

\^'products.html

but sublime text is not searching for this correctly. I don't know whether my syntax is incorrect or something but it's really confusing me.

Thanks in advance.

在此处输入图像描述

Try this:

Find: products\.html(.*?)'
Replace: $1.html'

截屏

Use this if your strings are

products.htmlcar
products.htmlcar_paper
products.htmlhome-decorative_air-freshener
^products.html

if your strings have ' a

^'products.html

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