简体   繁体   English

正则表达式替换 Webstorm 中的 mixin

[英]Regexp to replace mixin in Webstorm

I am using a mixin to theme colors in sass.我在 sass 中使用 mixin 主题颜色。

Now I want to get rid of it in my codebase and replace it with css custom properties.现在我想在我的代码库中摆脱它并用 css 自定义属性替换它。

the input would look like this:输入看起来像这样:

.myClass {
  @include themify('color', 'color-primary-light');
}

and the output should be:并且输出应该是:

.myClass {
  color: var(--color-primary-light);
}

my RegEx to capture the values is : @include themify\\("(.*)", "(.*)"\\);我捕获值的正则@include themify\\("(.*)", "(.*)"\\);是: @include themify\\("(.*)", "(.*)"\\);

you can try it right here: https://regex101.com/r/qzNhjF/1你可以在这里尝试: https : //regex101.com/r/qzNhjF/1

however, webstorm does not seem to recognize it in find / replace.但是,webstorm 似乎在查找/替换中没有识别它。 RegEx checkbox is enabled. RegEx 复选框已启用。

In your example you provide this code:在您的示例中,您提供以下代码:

.myClass {
  @include themify('color', 'color-primary-light');
}

Which will be matched by哪个将匹配

@include themify\('(.*)', '(.*)'\);

In https://regex101.com/r/qzNhjF/1 you provide this code:https://regex101.com/r/qzNhjF/1 中,您提供以下代码:

@include themify("color", "color-primary-light");

which will be matched by这将匹配

@include themify\("(.*)", "(.*)"\);

Maybe you are looking for the regex with single quotes in you webstorm?也许您正在 webstorm 中寻找带单引号正则表达式

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

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