I'm working on a CSS file in Dreamweaver. There are 100's of lines like this:
.ab_{background-image:url(../path/path/path/path/xxxxx.jpg);background-repeat:no-repeat;}
ab_ must stay the same
xxxxx is different. Example, xxx01, xxx02, etc.
ab_xxxxx is what I want to append.
I want to get xxxxx
value and put it near the beginning, after the ab_ like this:
.ab_xxxxxx{background-image:url(../path01/path02/path03/path04/xxxxx.jpg);background-repeat:no-repeat;}
so another one would be
.ab_xxxx45{background-image:url(../path01/path02/path03/path04/xxx45.jpg);background-repeat:no-repeat;}
I'm not sure if this possible, I know regular expressions can be tricky, but if this is possible could someone point in me in the right direction?
Find: \\.ab_(.+/([^/]+)\\.jpg)
Replace: .ab_$2$1
Explanation:
.ab_
matches the literal text ".ab_".
(.+/([^/]+)\\.jpg)
matches up to ".jpg" and stores the result in $1
.
/([^/]+)
matches a forward slash then captures anything that is not a forward slash up to ".jpg" and stores it in $2
.
Not sure about dreamweaver regex, but try this in notepad++
search : ^\\.ab_(.*)\\/(.*).jpg(.*)$
replace with : .ab_\\2\\1/\\2.jpg\\3
It's not the most accurate regex, but it seems to work, especially for something that must be a one-time deal.
Input :
.ab_{background-image:url(../path/path/path/path/xxxxx.jpg);background-repeat:no-repeat;}
.ab_{background-image:url(../path/path/path/path/xxxxx1.jpg);background-repeat:no-repeat;}
.ab_{background-image:url(../path/path/path/path/xxxxx2.jpg);background-repeat:no-repeat;}
.ab_{background-image:url(../path/path/path/path/xxxxx3.jpg);background-repeat:no-repeat;}
Output :
.ab_xxxxx{background-image:url(../path/path/path/path/xxxxx.jpg);background-repeat:no-repeat;}
.ab_xxxxx1{background-image:url(../path/path/path/path/xxxxx1.jpg);background-repeat:no-repeat;}
.ab_xxxxx2{background-image:url(../path/path/path/path/xxxxx2.jpg);background-repeat:no-repeat;}
.ab_xxxxx3{background-image:url(../path/path/path/path/xxxxx3.jpg);background-repeat:no-repeat;}
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.