简体   繁体   English

SCSS / ERB URL的Sublime Text 2正则表达式

[英]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. 我一直试图整夜都围绕着Sublime Text正则表达式,但是却一无所获。 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. 这非常适合将我的.scss文件转换为.scss.erb文件。

For anyone else with the same problem: 对于其他有相同问题的人:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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