简体   繁体   中英

Sublime Text 2 regular expression for SCSS/ERB URLs

I've been trying to wrap my head around Sublime Text regular expressions all evening and haven't gotten anywhere. With an example string of:

url(/assets/content.png);

How can I replace the ends to produce this?

url('<%= asset_path('content.png') %>');

While I was able to construct expressions that match this pattern, namely

\/assets\/\w*.\w{3}\);

I can't figure out how to replace the appropriate pieces. What should I do?

Turns out that I needed to change my thinking. Rather than preserving the content and changing the tags, I had to take the entire found string, grab the capture group containing the content, and replace the entire line. This worked great for converting my .scss file to an .scss.erb file.

For anyone else with the same problem:

SCSS-> SCSS / ERB正则表达式,用于Sublime Text 2

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