-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path298F4E21-BB34-47A6-96BB-A51C22BD52FB.codesnippet
42 lines (39 loc) · 1.68 KB
/
298F4E21-BB34-47A6-96BB-A51C22BD52FB.codesnippet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>my_regex2str_oc_func</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>- (BOOL)textRegex:(NSString *)targetStr {
//1. 数字:^[0-9]*$
//2. m-n位的数字:^\d{m,n}$
//3. 汉字:^[\u4e00-\u9fa5]{0,}$
//4. 英文和数字:^[A-Za-z0-9]{4,40}$
//5. 手机号码:^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$
//6. 身份证号(15位、18位数字):^\d{15}|\d{18}$
//7. 整数或者小数:"^([1-9][0-9]*.?|0.)[0-9]*$"
//8. 12位数字字母:"^[1-5a-z]{12}$"
NSString *check = @"^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$";
NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:check options:NSRegularExpressionCaseInsensitive error:nil];
NSRange range = [regular rangeOfFirstMatchInString:targetStr options:NSMatchingReportProgress range:NSMakeRange(0, targetStr.length)];
return [targetStr substringWithRange:range];
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>298F4E21-BB34-47A6-96BB-A51C22BD52FB</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Generic</string>
<key>IDECodeSnippetSummary</key>
<string>正则表达式 OC</string>
<key>IDECodeSnippetTitle</key>
<string>my_regex2str_oc_func</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>