开发者

objective C Regex

开发者 https://www.devze.com 2023-04-03 04:41 出处:网络
What is the objective C Regex equivalent for -webkit-text-size-adjust\\s*:\\s*.*[\'|\"|;|>] where I would like to test

What is the objective C Regex equivalent for

-webkit-text-size-adjust\s*:\s*.*['|"|;|>]

where I would like to test

-webkit-text-size-adjust (any number of spaces) : (any number of spaces) (any length of characters) end with ('|"|;|>).

so this should pass

    -webkit-text-size-adjust  :     saasasa;
    -webkit-text-size-adjust  :     saasasa"
    -webkit-text-size-adjust  :     saasasa>
    -webkit-text-size-adjust  :     saasasa'
    -webkit-text-size-adjust  :     "saasasa";
    -webkit-text-size-adjust  :     'saa开发者_高级运维sasa';
    -webkit-text-size-adjust  :     "100%";
    -webkit-text-size-adjust  :     '100%';
    -webkit-text-size-adjust  :     100%;
    -webkit-text-size-adjust  :     100;'
    -webkit-text-size-adjust  :     "100";
    -webkit-text-size-adjust  :     '100'>
    -webkit-text-size-adjust  :     saasasa"

and this should fail

-webkit-text-size-adjust  :     saasasa}
-webkit-text-size-adjust  :     saasasa^

etc


NSError* yourError = nil;
NSRegularExpression* yourRegex = [NSRegularExpression
   regularExpressionWithPattern:@"\s*:\s*['\"]?[a-z0-9]+%?['\";>]+" 
                        options:NSRegularExpressionCaseInsensitive
                          error:&yourError];

[yourRegex numberOfMatchesInString:yourString 
                           options:NSRegularExpressionCaseInsensitive 
                             range:NSMakeRange(0, [yourString  length])];
0

精彩评论

暂无评论...
验证码 换一张
取 消