正则表达式:查找jQuery中所有没有前缀的类 [英] Regex: find all classes in jquery that dont have prefix
问题描述
我正在尝试在Jrent文件中找到所有不带p-前缀的css类.
I'm trying to find all the css classes in a Jquery file that arent prefixed with p- yet.
这使我获得了所有首先引用的类,但仍然错过了下面的摘录.任何人都可以帮助改善这一点吗?
This got me all the classes that are referenced first but still misses some from the snippet below. Can anyone help improve this?
\('\.(?!p-)
以下是我正在搜索的来源的摘录:
Here is an extract from the source I'm searching through:
animateSubElements: function(num) {
var newNum = (typeof(num) == 'number' ? num : 1);
TweenMax.to($('.p-section.current .col-right'), 0.3, {alpha: 0});
TweenMax.to($('.p-section.current .col-right:nth-child(' + newNum + ')'), 0.3, {alpha: 1, delay: 0.3});
},
这里是测试建议的地方: http://regexr.com/39da9
Here is a place to test suggestions: http://regexr.com/39da9
推荐答案
尝试以下表达式:
\('[^\)]*\.\K((?!p-)[a-z0-9\-\.]+)
http://regex101.com/r/fA2eK4/1
说明:
[^\)]*
-匹配除)
以外的任何字符,因为我们仅搜索(
和)
[^\)]*
- match any characters with the exception of )
as we search only text between (
and )
(?!p-)
-无前缀p-
\K
-从该标记开始的匹配返回文本
\K
- as match return text starting from this mark
[a-z0-9\-\.]+
-仅与类名称匹配(包括名称中有效的字符)
[a-z0-9\-\.]+
- match for class name only (include characters which is valid in names)
崇高文本搜索使用
Sublime Text search uses the Boost syntax for regular expressions.
这篇关于正则表达式:查找jQuery中所有没有前缀的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!