有一种向所有CSS类& amp;添加前缀的快速方法.身份证? [英] There a quick way to add prefixes to all CSS classes & ID's?

查看:47
本文介绍了有一种向所有CSS类& amp;添加前缀的快速方法.身份证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要快速为所有类和ID添加前缀,这是一个很大的CSS文件.我在想一个快速的正则表达式字符串,但到目前为止,我失败了.有什么想法吗?

I need to quickly add prefixes to all of of my classes and ID's and it's quite a large CSS file. I was thinking a quick regex string but so far I've failed. Any ideas?

我已经尝试过简单的事情,例如:

I've tried simple things like:

\#([A-z0-9]+) {

哪位让我替换为#prefix_ $ 1,但其中没有考虑到这一点:

Which will let me replace with #prefix_$1 but it doesn't take into account:

#id {
#id.class
#id,

等我不能只替换所有的[[a-z0-9]],因为它会尝试获取背景色等等.

etc. I can't just replace all #[a-z0-9] because it will attempt to grab background-colors and so on.

我还需要替换所有类,这对我来说更加令人困惑.

I also need to replace all the classes, which is even more confusing for me.

推荐答案

您可以搜索:

\.(-?[_ a-zA-Z] + [_ a-zA-Z0-9-] *)[^}] + {

\#(-?[_ a-zA-Z] + [_ a-zA-Z0-9-] *)[^}] + {

应该找到您所有的班级名称和ID名称

Should find all your class names and id names

与RegExr一起使用:

With RegExr, use this:

(?< =#| \.)(-?[_ a-zA-Z] + [_ a-zA-Z0-9-] *)(?= [^}] + {)

这是指向Google CSS的测试的链接 http://regexr.com?2ugv1

Here's a link to a test on google's CSS http://regexr.com?2ugv1

这篇关于有一种向所有CSS类&amp; amp;添加前缀的快速方法.身份证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆