Skip to content

Commit 93fac4e

Browse files
committed
更新Regex的README.md
1 parent 226bba4 commit 93fac4e

9 files changed

Lines changed: 70 additions & 0 deletions

File tree

RegularExpression/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### 正则表达式NSRegularExpression
2+
3+
在这个demo里,通过以下三种方式学习正则表达式:
4+
5+
1. 进行文本查找、替换。
6+
2. 验证用户输入文本是否符合格式要求。
7+
3. 自动格式化用户输入文本。
8+
9+
`First``Second``Third`三个视图控制器对应实现上述三项功能。
10+
11+
详细介绍查看下面文章:
12+
13+
<https://github.com/pro648/tips/wiki/正则表达式NSRegularExpression>
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<!--
4+
.xcodeSampleCode.plist
5+
RegularExpression
6+
7+
Created by ad on 25/12/2017.
8+
Copyright (c) 2017 ___ORGANIZATIONNAME___. All rights reserved.
9+
-->
10+
<plist version="1.0">
11+
<dict>
12+
13+
</dict>
14+
</plist>

RegularExpression/RegularExpression.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
6002966A1ED95EAF00F57A86 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4646
600296731ED96ED900F57A86 /* SearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchViewController.h; sourceTree = "<group>"; };
4747
600296741ED96ED900F57A86 /* SearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchViewController.m; sourceTree = "<group>"; };
48+
6023D2D01FF134D400E9AA6C /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
4849
60E4F8831EDACD8800F94C16 /* SecondViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondViewController.h; sourceTree = "<group>"; };
4950
60E4F8841EDACD8800F94C16 /* SecondViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondViewController.m; sourceTree = "<group>"; };
5051
60E4F8861EDACD9B00F94C16 /* ThirdViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThirdViewController.h; sourceTree = "<group>"; };
@@ -72,6 +73,7 @@
7273
6002963F1ED95EAF00F57A86 = {
7374
isa = PBXGroup;
7475
children = (
76+
6023D2D01FF134D400E9AA6C /* README.md */,
7577
6002964A1ED95EAF00F57A86 /* RegularExpression */,
7678
600296671ED95EAF00F57A86 /* RegularExpressionTests */,
7779
600296491ED95EAF00F57A86 /* Products */,

RegularExpression/RegularExpression/FirstViewController.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ - (void)searchText:(NSString *)string inTextView:(UITextView *)textView options:
116116
[visibleAttributedText addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:matchRange];
117117
}
118118

119+
// 注释5和6可以合并在一起,如下:
120+
/*
121+
[regex enumerateMatchesInString:visibleText options:NSMatchingReportCompletion range:visibleTextRange usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) {
122+
NSRange matchRange = result.range;
123+
[visibleAttributedText addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:matchRange];
124+
}];
125+
*/
126+
119127
// 7.Replace the range of the attributed string that we just highlighted. First, create a CFRange from the NSRange of the visible range.
120128
CFRange visibleRange_CF = CFRangeMake(visibleRange.location, visibleRange.length);
121129

RegularExpression模板/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### 正则表达式NSRegularExpression
2+
3+
这个demo是[正则表达式NSRegularExpression](https://github.com/pro648/tips/wiki/正则表达式NSRegularExpression)这篇文章的模板。在这篇文章中,通过以下三种方式学习正则表达式:
4+
5+
1. 进行文本查找、替换。
6+
2. 验证用户输入文本是否符合格式要求。
7+
3. 自动格式化用户输入文本。
8+
9+
`First``Second``Third`三个视图控制器对应实现上述三项功能。
10+
11+
详细介绍查看下面文章:
12+
13+
<https://github.com/pro648/tips/wiki/正则表达式NSRegularExpression>
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<!--
4+
.xcodeSampleCode.plist
5+
RegularExpression
6+
7+
Created by ad on 25/12/2017.
8+
Copyright (c) 2017 ___ORGANIZATIONNAME___. All rights reserved.
9+
-->
10+
<plist version="1.0">
11+
<dict>
12+
13+
</dict>
14+
</plist>

RegularExpression模板/RegularExpression.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
6002965E1ED95EAF00F57A86 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6002965C1ED95EAF00F57A86 /* LaunchScreen.storyboard */; };
1616
600296691ED95EAF00F57A86 /* RegularExpressionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 600296681ED95EAF00F57A86 /* RegularExpressionTests.m */; };
1717
600296751ED96ED900F57A86 /* SearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 600296741ED96ED900F57A86 /* SearchViewController.m */; };
18+
6023D2D41FF1377D00E9AA6C /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 6023D2D31FF1377D00E9AA6C /* README.md */; };
1819
60E4F8851EDACD8800F94C16 /* SecondViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60E4F8841EDACD8800F94C16 /* SecondViewController.m */; };
1920
60E4F8881EDACD9B00F94C16 /* ThirdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 60E4F8871EDACD9B00F94C16 /* ThirdViewController.m */; };
2021
/* End PBXBuildFile section */
@@ -45,6 +46,7 @@
4546
6002966A1ED95EAF00F57A86 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4647
600296731ED96ED900F57A86 /* SearchViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchViewController.h; sourceTree = "<group>"; };
4748
600296741ED96ED900F57A86 /* SearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchViewController.m; sourceTree = "<group>"; };
49+
6023D2D31FF1377D00E9AA6C /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
4850
60E4F8831EDACD8800F94C16 /* SecondViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SecondViewController.h; sourceTree = "<group>"; };
4951
60E4F8841EDACD8800F94C16 /* SecondViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SecondViewController.m; sourceTree = "<group>"; };
5052
60E4F8861EDACD9B00F94C16 /* ThirdViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThirdViewController.h; sourceTree = "<group>"; };
@@ -72,6 +74,7 @@
7274
6002963F1ED95EAF00F57A86 = {
7375
isa = PBXGroup;
7476
children = (
77+
6023D2D31FF1377D00E9AA6C /* README.md */,
7578
6002964A1ED95EAF00F57A86 /* RegularExpression */,
7679
600296671ED95EAF00F57A86 /* RegularExpressionTests */,
7780
600296491ED95EAF00F57A86 /* Products */,
@@ -209,6 +212,7 @@
209212
files = (
210213
6002965E1ED95EAF00F57A86 /* LaunchScreen.storyboard in Resources */,
211214
6002965B1ED95EAF00F57A86 /* Assets.xcassets in Resources */,
215+
6023D2D41FF1377D00E9AA6C /* README.md in Resources */,
212216
600296591ED95EAF00F57A86 /* Main.storyboard in Resources */,
213217
);
214218
runOnlyForDeploymentPostprocessing = 0;

0 commit comments

Comments
 (0)