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])];
精彩评论