├── .gitignore ├── .travis.yml ├── AXRegex.podspec ├── Example ├── AXRegex.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── AXRegex-Example.xcscheme ├── AXRegex.xcworkspace │ └── contents.xcworkspacedata ├── AXRegex │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ └── ViewController.swift ├── Podfile ├── Podfile.lock ├── Screenshots │ └── Demo.png └── Tests │ ├── Info.plist │ └── Tests.swift ├── LICENSE ├── Pod ├── Regex.swift └── RegexPattern.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | # 6 | build/ 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | profile 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # CocoaPods 25 | # 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 29 | # 30 | Pods/ 31 | 32 | # Carthage 33 | # 34 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 35 | # Carthage/Checkouts 36 | 37 | Carthage/Build 38 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | language: objective-c 6 | # cache: cocoapods 7 | # podfile: Example/Podfile 8 | # before_install: 9 | # - gem install cocoapods # Since Travis is not always on latest version 10 | - pod install --project-directory=Example 11 | install: 12 | - gem install xcpretty --no-rdoc --no-ri --no-document --quiet 13 | script: 14 | - set -o pipefail && xcodebuild test -workspace Example/AXRegex.xcworkspace -scheme AXRegex-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty -c 15 | - pod lib lint --quick 16 | -------------------------------------------------------------------------------- /AXRegex.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "AXRegex" 3 | s.version = "0.2.2" 4 | s.summary = "A easy way to use regex in Swift." 5 | 6 | s.description = <<-DESC 7 | Try to implement a easy way to use regex in Swift. 8 | DESC 9 | 10 | s.homepage = "https://github.com/ArthurXHK/AXRegex" 11 | s.license = { :type => 'Apache License 2.0', :file => 'LICENSE' } 12 | s.author = { "Arthur XU" => "arthurk.dev@gmail.com" } 13 | s.source = { 14 | :git => "https://github.com/ArthurXHK/AXRegex.git", 15 | :tag => s.version.to_s 16 | } 17 | 18 | s.platform = :ios, '8.0' 19 | s.requires_arc = true 20 | 21 | s.source_files = 'Pod/*.swift' 22 | s.frameworks = 'Foundation' 23 | 24 | end 25 | -------------------------------------------------------------------------------- /Example/AXRegex.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0E7E4DA030E78892CD05A766 /* Pods_AXRegex_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 287EABE9EDB9EDDF06CD6CB9 /* Pods_AXRegex_Tests.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 11 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 12 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; }; 13 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 14 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 15 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 16 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 17 | F01E8585677D5A53B63CB880 /* Pods_AXRegex_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0EE7371A4C2D4F87C986E2C0 /* Pods_AXRegex_Example.framework */; settings = {ATTRIBUTES = (Weak, ); }; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 26 | remoteInfo = AXRegex; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 0EE7371A4C2D4F87C986E2C0 /* Pods_AXRegex_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AXRegex_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 123F53958B7CB16FAB7537DB /* AXRegex.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = AXRegex.podspec; path = ../AXRegex.podspec; sourceTree = ""; }; 33 | 287EABE9EDB9EDDF06CD6CB9 /* Pods_AXRegex_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_AXRegex_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 384AD16F967612B068D6C95D /* Pods-AXRegex_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AXRegex_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AXRegex_Tests/Pods-AXRegex_Tests.debug.xcconfig"; sourceTree = ""; }; 35 | 3A61564462E675B17D95BC2F /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 36 | 521193F72F555FF850592367 /* Pods-AXRegex_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AXRegex_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-AXRegex_Tests/Pods-AXRegex_Tests.release.xcconfig"; sourceTree = ""; }; 37 | 607FACD01AFB9204008FA782 /* AXRegex_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AXRegex_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 38 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 39 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 40 | 607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 41 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 43 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 44 | 607FACE51AFB9204008FA782 /* AXRegex_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AXRegex_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 45 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 47 | 8E24B3681BCFEE9B00F2305C /* AXRegex.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AXRegex.framework; path = "Pods/../build/Debug-iphoneos/AXRegex.framework"; sourceTree = ""; }; 48 | 9522DA0C43464D2ECE998276 /* Pods-AXRegex_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AXRegex_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-AXRegex_Example/Pods-AXRegex_Example.release.xcconfig"; sourceTree = ""; }; 49 | AB92512DE237AC204DF0C07B /* Pods-AXRegex_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AXRegex_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AXRegex_Example/Pods-AXRegex_Example.debug.xcconfig"; sourceTree = ""; }; 50 | B80CE652846C99B202BCB9F8 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | F01E8585677D5A53B63CB880 /* Pods_AXRegex_Example.framework in Frameworks */, 59 | ); 60 | runOnlyForDeploymentPostprocessing = 0; 61 | }; 62 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 63 | isa = PBXFrameworksBuildPhase; 64 | buildActionMask = 2147483647; 65 | files = ( 66 | 0E7E4DA030E78892CD05A766 /* Pods_AXRegex_Tests.framework in Frameworks */, 67 | ); 68 | runOnlyForDeploymentPostprocessing = 0; 69 | }; 70 | /* End PBXFrameworksBuildPhase section */ 71 | 72 | /* Begin PBXGroup section */ 73 | 607FACC71AFB9204008FA782 = { 74 | isa = PBXGroup; 75 | children = ( 76 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 77 | 607FACD21AFB9204008FA782 /* Example for AXRegex */, 78 | 607FACE81AFB9204008FA782 /* Tests */, 79 | 607FACD11AFB9204008FA782 /* Products */, 80 | 907EB5D5247044015229076F /* Pods */, 81 | 999F72DD539142F0AE8649F3 /* Frameworks */, 82 | ); 83 | sourceTree = ""; 84 | }; 85 | 607FACD11AFB9204008FA782 /* Products */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 607FACD01AFB9204008FA782 /* AXRegex_Example.app */, 89 | 607FACE51AFB9204008FA782 /* AXRegex_Tests.xctest */, 90 | ); 91 | name = Products; 92 | sourceTree = ""; 93 | }; 94 | 607FACD21AFB9204008FA782 /* Example for AXRegex */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 98 | 607FACD71AFB9204008FA782 /* ViewController.swift */, 99 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 100 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 101 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 102 | 607FACD31AFB9204008FA782 /* Supporting Files */, 103 | ); 104 | name = "Example for AXRegex"; 105 | path = AXRegex; 106 | sourceTree = ""; 107 | }; 108 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 607FACD41AFB9204008FA782 /* Info.plist */, 112 | ); 113 | name = "Supporting Files"; 114 | sourceTree = ""; 115 | }; 116 | 607FACE81AFB9204008FA782 /* Tests */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 120 | 607FACE91AFB9204008FA782 /* Supporting Files */, 121 | ); 122 | path = Tests; 123 | sourceTree = ""; 124 | }; 125 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 607FACEA1AFB9204008FA782 /* Info.plist */, 129 | ); 130 | name = "Supporting Files"; 131 | sourceTree = ""; 132 | }; 133 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 123F53958B7CB16FAB7537DB /* AXRegex.podspec */, 137 | 3A61564462E675B17D95BC2F /* README.md */, 138 | B80CE652846C99B202BCB9F8 /* LICENSE */, 139 | ); 140 | name = "Podspec Metadata"; 141 | sourceTree = ""; 142 | }; 143 | 907EB5D5247044015229076F /* Pods */ = { 144 | isa = PBXGroup; 145 | children = ( 146 | AB92512DE237AC204DF0C07B /* Pods-AXRegex_Example.debug.xcconfig */, 147 | 9522DA0C43464D2ECE998276 /* Pods-AXRegex_Example.release.xcconfig */, 148 | 384AD16F967612B068D6C95D /* Pods-AXRegex_Tests.debug.xcconfig */, 149 | 521193F72F555FF850592367 /* Pods-AXRegex_Tests.release.xcconfig */, 150 | ); 151 | name = Pods; 152 | sourceTree = ""; 153 | }; 154 | 999F72DD539142F0AE8649F3 /* Frameworks */ = { 155 | isa = PBXGroup; 156 | children = ( 157 | 8E24B3681BCFEE9B00F2305C /* AXRegex.framework */, 158 | 0EE7371A4C2D4F87C986E2C0 /* Pods_AXRegex_Example.framework */, 159 | 287EABE9EDB9EDDF06CD6CB9 /* Pods_AXRegex_Tests.framework */, 160 | ); 161 | name = Frameworks; 162 | sourceTree = ""; 163 | }; 164 | /* End PBXGroup section */ 165 | 166 | /* Begin PBXNativeTarget section */ 167 | 607FACCF1AFB9204008FA782 /* AXRegex_Example */ = { 168 | isa = PBXNativeTarget; 169 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AXRegex_Example" */; 170 | buildPhases = ( 171 | 00F3636C79534AB0E1E446F4 /* Check Pods Manifest.lock */, 172 | 607FACCC1AFB9204008FA782 /* Sources */, 173 | 607FACCD1AFB9204008FA782 /* Frameworks */, 174 | 607FACCE1AFB9204008FA782 /* Resources */, 175 | CB2B38BD5DAAF31C203A49D9 /* Embed Pods Frameworks */, 176 | 1C19236EFF275C43DCFAD6AE /* Copy Pods Resources */, 177 | ); 178 | buildRules = ( 179 | ); 180 | dependencies = ( 181 | ); 182 | name = AXRegex_Example; 183 | productName = AXRegex; 184 | productReference = 607FACD01AFB9204008FA782 /* AXRegex_Example.app */; 185 | productType = "com.apple.product-type.application"; 186 | }; 187 | 607FACE41AFB9204008FA782 /* AXRegex_Tests */ = { 188 | isa = PBXNativeTarget; 189 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AXRegex_Tests" */; 190 | buildPhases = ( 191 | B26D56EAA37167AD57AE1677 /* Check Pods Manifest.lock */, 192 | 607FACE11AFB9204008FA782 /* Sources */, 193 | 607FACE21AFB9204008FA782 /* Frameworks */, 194 | 607FACE31AFB9204008FA782 /* Resources */, 195 | 0D868968BDD81355FBD0B8A1 /* Embed Pods Frameworks */, 196 | FBC77A49E136494880A9A7E6 /* Copy Pods Resources */, 197 | ); 198 | buildRules = ( 199 | ); 200 | dependencies = ( 201 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 202 | ); 203 | name = AXRegex_Tests; 204 | productName = Tests; 205 | productReference = 607FACE51AFB9204008FA782 /* AXRegex_Tests.xctest */; 206 | productType = "com.apple.product-type.bundle.unit-test"; 207 | }; 208 | /* End PBXNativeTarget section */ 209 | 210 | /* Begin PBXProject section */ 211 | 607FACC81AFB9204008FA782 /* Project object */ = { 212 | isa = PBXProject; 213 | attributes = { 214 | LastSwiftUpdateCheck = 0700; 215 | LastUpgradeCheck = 0700; 216 | ORGANIZATIONNAME = CocoaPods; 217 | TargetAttributes = { 218 | 607FACCF1AFB9204008FA782 = { 219 | CreatedOnToolsVersion = 6.3.1; 220 | }; 221 | 607FACE41AFB9204008FA782 = { 222 | CreatedOnToolsVersion = 6.3.1; 223 | TestTargetID = 607FACCF1AFB9204008FA782; 224 | }; 225 | }; 226 | }; 227 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "AXRegex" */; 228 | compatibilityVersion = "Xcode 3.2"; 229 | developmentRegion = English; 230 | hasScannedForEncodings = 0; 231 | knownRegions = ( 232 | en, 233 | Base, 234 | ); 235 | mainGroup = 607FACC71AFB9204008FA782; 236 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 237 | projectDirPath = ""; 238 | projectRoot = ""; 239 | targets = ( 240 | 607FACCF1AFB9204008FA782 /* AXRegex_Example */, 241 | 607FACE41AFB9204008FA782 /* AXRegex_Tests */, 242 | ); 243 | }; 244 | /* End PBXProject section */ 245 | 246 | /* Begin PBXResourcesBuildPhase section */ 247 | 607FACCE1AFB9204008FA782 /* Resources */ = { 248 | isa = PBXResourcesBuildPhase; 249 | buildActionMask = 2147483647; 250 | files = ( 251 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 252 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 253 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 254 | ); 255 | runOnlyForDeploymentPostprocessing = 0; 256 | }; 257 | 607FACE31AFB9204008FA782 /* Resources */ = { 258 | isa = PBXResourcesBuildPhase; 259 | buildActionMask = 2147483647; 260 | files = ( 261 | ); 262 | runOnlyForDeploymentPostprocessing = 0; 263 | }; 264 | /* End PBXResourcesBuildPhase section */ 265 | 266 | /* Begin PBXShellScriptBuildPhase section */ 267 | 00F3636C79534AB0E1E446F4 /* Check Pods Manifest.lock */ = { 268 | isa = PBXShellScriptBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | ); 272 | inputPaths = ( 273 | ); 274 | name = "Check Pods Manifest.lock"; 275 | outputPaths = ( 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | shellPath = /bin/sh; 279 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 280 | showEnvVarsInLog = 0; 281 | }; 282 | 0D868968BDD81355FBD0B8A1 /* Embed Pods Frameworks */ = { 283 | isa = PBXShellScriptBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | ); 287 | inputPaths = ( 288 | ); 289 | name = "Embed Pods Frameworks"; 290 | outputPaths = ( 291 | ); 292 | runOnlyForDeploymentPostprocessing = 0; 293 | shellPath = /bin/sh; 294 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AXRegex_Tests/Pods-AXRegex_Tests-frameworks.sh\"\n"; 295 | showEnvVarsInLog = 0; 296 | }; 297 | 1C19236EFF275C43DCFAD6AE /* Copy Pods Resources */ = { 298 | isa = PBXShellScriptBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | ); 302 | inputPaths = ( 303 | ); 304 | name = "Copy Pods Resources"; 305 | outputPaths = ( 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | shellPath = /bin/sh; 309 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AXRegex_Example/Pods-AXRegex_Example-resources.sh\"\n"; 310 | showEnvVarsInLog = 0; 311 | }; 312 | B26D56EAA37167AD57AE1677 /* Check Pods Manifest.lock */ = { 313 | isa = PBXShellScriptBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | ); 317 | inputPaths = ( 318 | ); 319 | name = "Check Pods Manifest.lock"; 320 | outputPaths = ( 321 | ); 322 | runOnlyForDeploymentPostprocessing = 0; 323 | shellPath = /bin/sh; 324 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; 325 | showEnvVarsInLog = 0; 326 | }; 327 | CB2B38BD5DAAF31C203A49D9 /* Embed Pods Frameworks */ = { 328 | isa = PBXShellScriptBuildPhase; 329 | buildActionMask = 2147483647; 330 | files = ( 331 | ); 332 | inputPaths = ( 333 | ); 334 | name = "Embed Pods Frameworks"; 335 | outputPaths = ( 336 | ); 337 | runOnlyForDeploymentPostprocessing = 0; 338 | shellPath = /bin/sh; 339 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AXRegex_Example/Pods-AXRegex_Example-frameworks.sh\"\n"; 340 | showEnvVarsInLog = 0; 341 | }; 342 | FBC77A49E136494880A9A7E6 /* Copy Pods Resources */ = { 343 | isa = PBXShellScriptBuildPhase; 344 | buildActionMask = 2147483647; 345 | files = ( 346 | ); 347 | inputPaths = ( 348 | ); 349 | name = "Copy Pods Resources"; 350 | outputPaths = ( 351 | ); 352 | runOnlyForDeploymentPostprocessing = 0; 353 | shellPath = /bin/sh; 354 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AXRegex_Tests/Pods-AXRegex_Tests-resources.sh\"\n"; 355 | showEnvVarsInLog = 0; 356 | }; 357 | /* End PBXShellScriptBuildPhase section */ 358 | 359 | /* Begin PBXSourcesBuildPhase section */ 360 | 607FACCC1AFB9204008FA782 /* Sources */ = { 361 | isa = PBXSourcesBuildPhase; 362 | buildActionMask = 2147483647; 363 | files = ( 364 | 607FACD81AFB9204008FA782 /* ViewController.swift in Sources */, 365 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 366 | ); 367 | runOnlyForDeploymentPostprocessing = 0; 368 | }; 369 | 607FACE11AFB9204008FA782 /* Sources */ = { 370 | isa = PBXSourcesBuildPhase; 371 | buildActionMask = 2147483647; 372 | files = ( 373 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 374 | ); 375 | runOnlyForDeploymentPostprocessing = 0; 376 | }; 377 | /* End PBXSourcesBuildPhase section */ 378 | 379 | /* Begin PBXTargetDependency section */ 380 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 381 | isa = PBXTargetDependency; 382 | target = 607FACCF1AFB9204008FA782 /* AXRegex_Example */; 383 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 384 | }; 385 | /* End PBXTargetDependency section */ 386 | 387 | /* Begin PBXVariantGroup section */ 388 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 389 | isa = PBXVariantGroup; 390 | children = ( 391 | 607FACDA1AFB9204008FA782 /* Base */, 392 | ); 393 | name = Main.storyboard; 394 | sourceTree = ""; 395 | }; 396 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 397 | isa = PBXVariantGroup; 398 | children = ( 399 | 607FACDF1AFB9204008FA782 /* Base */, 400 | ); 401 | name = LaunchScreen.xib; 402 | sourceTree = ""; 403 | }; 404 | /* End PBXVariantGroup section */ 405 | 406 | /* Begin XCBuildConfiguration section */ 407 | 607FACED1AFB9204008FA782 /* Debug */ = { 408 | isa = XCBuildConfiguration; 409 | buildSettings = { 410 | ALWAYS_SEARCH_USER_PATHS = NO; 411 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 412 | CLANG_CXX_LIBRARY = "libc++"; 413 | CLANG_ENABLE_MODULES = YES; 414 | CLANG_ENABLE_OBJC_ARC = YES; 415 | CLANG_WARN_BOOL_CONVERSION = YES; 416 | CLANG_WARN_CONSTANT_CONVERSION = YES; 417 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 418 | CLANG_WARN_EMPTY_BODY = YES; 419 | CLANG_WARN_ENUM_CONVERSION = YES; 420 | CLANG_WARN_INT_CONVERSION = YES; 421 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 422 | CLANG_WARN_UNREACHABLE_CODE = YES; 423 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 424 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 425 | COPY_PHASE_STRIP = NO; 426 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 427 | ENABLE_STRICT_OBJC_MSGSEND = YES; 428 | ENABLE_TESTABILITY = YES; 429 | GCC_C_LANGUAGE_STANDARD = gnu99; 430 | GCC_DYNAMIC_NO_PIC = NO; 431 | GCC_NO_COMMON_BLOCKS = YES; 432 | GCC_OPTIMIZATION_LEVEL = 0; 433 | GCC_PREPROCESSOR_DEFINITIONS = ( 434 | "DEBUG=1", 435 | "$(inherited)", 436 | ); 437 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 438 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 439 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 440 | GCC_WARN_UNDECLARED_SELECTOR = YES; 441 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 442 | GCC_WARN_UNUSED_FUNCTION = YES; 443 | GCC_WARN_UNUSED_VARIABLE = YES; 444 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 445 | MTL_ENABLE_DEBUG_INFO = YES; 446 | ONLY_ACTIVE_ARCH = YES; 447 | SDKROOT = iphoneos; 448 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 449 | }; 450 | name = Debug; 451 | }; 452 | 607FACEE1AFB9204008FA782 /* Release */ = { 453 | isa = XCBuildConfiguration; 454 | buildSettings = { 455 | ALWAYS_SEARCH_USER_PATHS = NO; 456 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 457 | CLANG_CXX_LIBRARY = "libc++"; 458 | CLANG_ENABLE_MODULES = YES; 459 | CLANG_ENABLE_OBJC_ARC = YES; 460 | CLANG_WARN_BOOL_CONVERSION = YES; 461 | CLANG_WARN_CONSTANT_CONVERSION = YES; 462 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 463 | CLANG_WARN_EMPTY_BODY = YES; 464 | CLANG_WARN_ENUM_CONVERSION = YES; 465 | CLANG_WARN_INT_CONVERSION = YES; 466 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 467 | CLANG_WARN_UNREACHABLE_CODE = YES; 468 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 469 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 470 | COPY_PHASE_STRIP = NO; 471 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 472 | ENABLE_NS_ASSERTIONS = NO; 473 | ENABLE_STRICT_OBJC_MSGSEND = YES; 474 | GCC_C_LANGUAGE_STANDARD = gnu99; 475 | GCC_NO_COMMON_BLOCKS = YES; 476 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 477 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 478 | GCC_WARN_UNDECLARED_SELECTOR = YES; 479 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 480 | GCC_WARN_UNUSED_FUNCTION = YES; 481 | GCC_WARN_UNUSED_VARIABLE = YES; 482 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 483 | MTL_ENABLE_DEBUG_INFO = NO; 484 | SDKROOT = iphoneos; 485 | VALIDATE_PRODUCT = YES; 486 | }; 487 | name = Release; 488 | }; 489 | 607FACF01AFB9204008FA782 /* Debug */ = { 490 | isa = XCBuildConfiguration; 491 | baseConfigurationReference = AB92512DE237AC204DF0C07B /* Pods-AXRegex_Example.debug.xcconfig */; 492 | buildSettings = { 493 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 494 | FRAMEWORK_SEARCH_PATHS = "$(inherited)"; 495 | INFOPLIST_FILE = AXRegex/Info.plist; 496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 497 | MODULE_NAME = ExampleApp; 498 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 499 | PRODUCT_NAME = "$(TARGET_NAME)"; 500 | }; 501 | name = Debug; 502 | }; 503 | 607FACF11AFB9204008FA782 /* Release */ = { 504 | isa = XCBuildConfiguration; 505 | baseConfigurationReference = 9522DA0C43464D2ECE998276 /* Pods-AXRegex_Example.release.xcconfig */; 506 | buildSettings = { 507 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 508 | FRAMEWORK_SEARCH_PATHS = "$(inherited)"; 509 | INFOPLIST_FILE = AXRegex/Info.plist; 510 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 511 | MODULE_NAME = ExampleApp; 512 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 513 | PRODUCT_NAME = "$(TARGET_NAME)"; 514 | }; 515 | name = Release; 516 | }; 517 | 607FACF31AFB9204008FA782 /* Debug */ = { 518 | isa = XCBuildConfiguration; 519 | baseConfigurationReference = 384AD16F967612B068D6C95D /* Pods-AXRegex_Tests.debug.xcconfig */; 520 | buildSettings = { 521 | BUNDLE_LOADER = "$(TEST_HOST)"; 522 | FRAMEWORK_SEARCH_PATHS = "$(inherited)"; 523 | GCC_PREPROCESSOR_DEFINITIONS = ( 524 | "DEBUG=1", 525 | "$(inherited)", 526 | ); 527 | INFOPLIST_FILE = Tests/Info.plist; 528 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 529 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 530 | PRODUCT_NAME = "$(TARGET_NAME)"; 531 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AXRegex_Example.app/AXRegex_Example"; 532 | }; 533 | name = Debug; 534 | }; 535 | 607FACF41AFB9204008FA782 /* Release */ = { 536 | isa = XCBuildConfiguration; 537 | baseConfigurationReference = 521193F72F555FF850592367 /* Pods-AXRegex_Tests.release.xcconfig */; 538 | buildSettings = { 539 | BUNDLE_LOADER = "$(TEST_HOST)"; 540 | FRAMEWORK_SEARCH_PATHS = "$(inherited)"; 541 | INFOPLIST_FILE = Tests/Info.plist; 542 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 543 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 544 | PRODUCT_NAME = "$(TARGET_NAME)"; 545 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AXRegex_Example.app/AXRegex_Example"; 546 | }; 547 | name = Release; 548 | }; 549 | /* End XCBuildConfiguration section */ 550 | 551 | /* Begin XCConfigurationList section */ 552 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "AXRegex" */ = { 553 | isa = XCConfigurationList; 554 | buildConfigurations = ( 555 | 607FACED1AFB9204008FA782 /* Debug */, 556 | 607FACEE1AFB9204008FA782 /* Release */, 557 | ); 558 | defaultConfigurationIsVisible = 0; 559 | defaultConfigurationName = Release; 560 | }; 561 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AXRegex_Example" */ = { 562 | isa = XCConfigurationList; 563 | buildConfigurations = ( 564 | 607FACF01AFB9204008FA782 /* Debug */, 565 | 607FACF11AFB9204008FA782 /* Release */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "AXRegex_Tests" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | 607FACF31AFB9204008FA782 /* Debug */, 574 | 607FACF41AFB9204008FA782 /* Release */, 575 | ); 576 | defaultConfigurationIsVisible = 0; 577 | defaultConfigurationName = Release; 578 | }; 579 | /* End XCConfigurationList section */ 580 | }; 581 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 582 | } 583 | -------------------------------------------------------------------------------- /Example/AXRegex.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/AXRegex.xcodeproj/xcshareddata/xcschemes/AXRegex-Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /Example/AXRegex.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/AXRegex/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // AXRegex 4 | // 5 | // Created by Arthur XU on 10/15/2015. 6 | // Copyright (c) 2015 Arthur XU. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(application: UIApplication) { 23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 24 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(application: UIApplication) { 28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(application: UIApplication) { 33 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(application: UIApplication) { 37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 38 | } 39 | 40 | func applicationWillTerminate(application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/AXRegex/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/AXRegex/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | <html> 46 | <header/>
 <body>
 <div attribute="something">content</div>
 </body> 47 | </html> 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | -------------------------------------------------------------------------------- /Example/AXRegex/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/AXRegex/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/AXRegex/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // AXRegex 4 | // 5 | // Created by Arthur XU on 10/15/2015. 6 | // Copyright (c) 2015 Arthur XU. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import AXRegex 11 | 12 | class ViewController: UIViewController, UITextViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate, UITableViewDataSource { 13 | 14 | // MARK: - Variable - 15 | @IBOutlet weak var textView: UITextView! 16 | @IBOutlet weak var regexPicker: UIPickerView! 17 | @IBOutlet weak var resultTable: UITableView! 18 | 19 | var regexResult: RegexResult? 20 | var regexPattern: String = RegexPattern.HtmlTag 21 | 22 | // MARK: - Life Cycle - 23 | override func viewDidAppear(animated: Bool) { 24 | super.viewDidAppear(animated) 25 | self.refreshResult() 26 | } 27 | 28 | // MARK: - Private Methods - 29 | func refreshResult() { 30 | self.regexResult = textView.text =~ regexPattern 31 | resultTable.reloadData() 32 | if let row = self.regexResult?.matches.count where row>0 { 33 | resultTable.scrollToRowAtIndexPath(NSIndexPath(forRow: row-1, inSection: 0), atScrollPosition: .None, animated: true) 34 | } 35 | } 36 | 37 | // MARK: - Delegate - 38 | // MARK: UITextViewDelegate 39 | func textViewDidChange(textView: UITextView) { 40 | self.refreshResult() 41 | } 42 | 43 | // MARK: UIPickerViewDataSource 44 | func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { 45 | return 1 46 | } 47 | func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 48 | return 6 49 | } 50 | 51 | // MARK: UIPickerViewDelegate 52 | func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 53 | var title: String 54 | switch row { 55 | case 0: 56 | title = "Html Tag" 57 | case 1: 58 | title = "Email" 59 | case 2: 60 | title = "IP Address" 61 | case 3: 62 | title = "WebSite" 63 | case 4: 64 | title = "Number" 65 | case 5: 66 | title = "Chinese" 67 | default: 68 | title = "" 69 | } 70 | return title 71 | } 72 | func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 73 | switch row { 74 | case 0: 75 | regexPattern = RegexPattern.HtmlTag 76 | case 1: 77 | regexPattern = RegexPattern.Email 78 | case 2: 79 | regexPattern = RegexPattern.IPAddress 80 | case 3: 81 | regexPattern = RegexPattern.WebSite 82 | case 4: 83 | regexPattern = RegexPattern.Number 84 | case 5: 85 | regexPattern = RegexPattern.Chinese 86 | default: 87 | regexPattern = "" 88 | } 89 | self.refreshResult() 90 | } 91 | 92 | // MARK: UITableViewDataSource 93 | func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 94 | guard let result = regexResult else {return 0} 95 | return result.matches.count 96 | } 97 | func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 98 | let cell = UITableViewCell(style: .Default, reuseIdentifier: "Cell") 99 | if let match=regexResult?.matches[indexPath.row], label=cell.textLabel { 100 | label.text = match.content 101 | } 102 | return cell 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | use_frameworks! 3 | 4 | target 'AXRegex_Example', :exclusive => true do 5 | pod "AXRegex", :path => "../" 6 | end 7 | 8 | target 'AXRegex_Tests', :exclusive => true do 9 | pod "AXRegex", :path => "../" 10 | 11 | 12 | end 13 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AXRegex (0.2.2) 3 | 4 | DEPENDENCIES: 5 | - AXRegex (from `../`) 6 | 7 | EXTERNAL SOURCES: 8 | AXRegex: 9 | :path: ../ 10 | 11 | SPEC CHECKSUMS: 12 | AXRegex: c5318a39d28822eef3e72ac0d4c42603e10fe282 13 | 14 | COCOAPODS: 0.38.2 15 | -------------------------------------------------------------------------------- /Example/Screenshots/Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArthurXHK/AXRegex/4db61a0779fc31b7d1508bf1be0f24d085cd8300/Example/Screenshots/Demo.png -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import XCTest 3 | import AXRegex 4 | 5 | class Tests: XCTestCase { 6 | 7 | override func setUp() { 8 | super.setUp() 9 | // Put setup code here. This method is called before the invocation of each test method in the class. 10 | } 11 | 12 | override func tearDown() { 13 | // Put teardown code here. This method is called after the invocation of each test method in the class. 14 | super.tearDown() 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /Pod/Regex.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Regex.swift 3 | // AXRegex 4 | // 5 | // Created by Arthur XU on 13/10/15. 6 | // Copyright © 2015年 Arthur XU. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct RegexResult { 12 | 13 | public let text: String 14 | public var matches = [(content:String, range: NSRange, type: NSTextCheckingType)]() 15 | 16 | public init(_ text: String) { 17 | self.text = text 18 | } 19 | 20 | public var hasMatch: Bool { 21 | return self.matches.count>0 22 | } 23 | public var isCompleteMatch: Bool { 24 | guard self.matches.count==1 else {return false} 25 | return self.matches[0].content.characters.count==self.text.characters.count 26 | } 27 | } 28 | 29 | public struct Regex { 30 | 31 | public var regex: NSRegularExpression? 32 | 33 | public init(_ pattern: String, options: NSRegularExpressionOptions=[]) { 34 | do{ 35 | regex = try NSRegularExpression(pattern: pattern, options:options) 36 | } catch { 37 | print("Fail to init Regex with pattern[\(pattern)]") 38 | } 39 | } 40 | 41 | public func match(text: String) -> RegexResult { 42 | var result = RegexResult(text) 43 | guard let regex = self.regex else {return result} 44 | let matches = regex.matchesInString(text, options: .ReportCompletion, range: NSMakeRange(0, text.characters.count)) 45 | for matchResult in matches { 46 | let content = (text as NSString).substringWithRange(matchResult.range) 47 | result.matches.append((content, matchResult.range, matchResult.resultType)) 48 | } 49 | return result 50 | } 51 | } 52 | 53 | public func regexMatch(text: String, pattern: String, options: NSRegularExpressionOptions=[]) -> RegexResult { 54 | var result = RegexResult(text) 55 | do{ 56 | let regex = try NSRegularExpression(pattern: pattern, options:options) 57 | let matches = regex.matchesInString(text, options:.ReportCompletion, range: NSMakeRange(0, text.characters.count)) 58 | for matchResult in matches { 59 | let content = (text as NSString).substringWithRange(matchResult.range) 60 | result.matches.append((content, matchResult.range, matchResult.resultType)) 61 | } 62 | } catch { 63 | print("Fail to init Regex with pattern[\(pattern)]") 64 | } 65 | return result 66 | } 67 | 68 | infix operator =~ { 69 | associativity none 70 | precedence 130 71 | } 72 | public func =~ (lhs: String, rhs: String) -> RegexResult { 73 | return regexMatch(lhs, pattern: rhs) 74 | } 75 | 76 | extension String { 77 | public func regex(pattern: String) -> RegexResult { 78 | return regexMatch(self, pattern: pattern) 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Pod/RegexPattern.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RegexPattern.swift 3 | // Pods 4 | // 5 | // Created by Arthur XU on 17/10/15. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | public struct RegexPattern { 12 | 13 | public static let Email: String = { 14 | return "([a-zA-Z0-9_\\.-]+)@([a-zA-Z0-9\\.-]+)\\.([a-zA-Z\\.]{2,6})" 15 | }() 16 | public static let WebSite: String = { 17 | return "(https?:\\/\\/)?([a-zA-Z0-9\\.-]+)\\.([a-zA-Z\\.]{2,6})([\\/\\w \\.-]*)*\\/?" 18 | }() 19 | public static let IPAddress: String = { 20 | return "(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" 21 | }() 22 | public static let HtmlTag: String = { 23 | return "<[\\/]?[a-zA-Z]+(\\s+[a-zA-Z]+\\s*[=]\\s*[\"]\\w+[\"])*\\s*(?:[\\/]?|>\\w*<\\/[a-zA-Z]+)>" 24 | }() 25 | public static let Number: String = { 26 | return "[0-9]+([.][0-9]+)?" 27 | }() 28 | public static let Chinese: String = { 29 | return "[\\u4e00-\\u9fa5]+" 30 | }() 31 | 32 | public static func userName(lowerLimit: UInt, upperLimit: UInt) -> String { 33 | return "[a-zA-Z][a-zA-Z0-9_]{\(lowerLimit-1),\(upperLimit-1)}" 34 | } 35 | public static func password(lowerLimit: UInt, upperLimit: UInt) -> String { 36 | return "[a-zA-Z0-9_]{\(lowerLimit-1),\(upperLimit-1)}" 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AXRegex 2 | Let's use Regex in a easy way with Swift. 3 | 4 | [![CI Status](http://img.shields.io/travis/Arthur XU/AXRegex.svg?style=flat)](https://travis-ci.org/Arthur XU/AXRegex) 5 | [![Version](https://img.shields.io/cocoapods/v/AXRegex.svg?style=flat)](http://cocoapods.org/pods/AXRegex) 6 | [![License](https://img.shields.io/cocoapods/l/AXRegex.svg?style=flat)](http://cocoapods.org/pods/AXRegex) 7 | [![Platform](https://img.shields.io/cocoapods/p/AXRegex.svg?style=flat)](http://cocoapods.org/pods/AXRegex) 8 | 9 | ## Why 10 | 11 | Just want to implement a easy way to use regex in Swift. 12 | 13 | 简简单单调用正则表达式 ( ̄^ ̄)ゞ 14 | 15 | ## Usage 16 | 17 | You can match regex like this: 18 | 19 | 你可以这样用: 20 | 21 | ```swift 22 | let regex = Regex("^[a-zA-Z0-9_-]{6,18}$") 23 | regex.match("userNameA") 24 | regex.match("userNameB") 25 | ``` 26 | 27 | or this: 28 | 29 | 或者这样用: 30 | 31 | ```swift 32 | regexMatch("userName", pattern: "^[a-zA-Z0-9_-]{6,18}$") 33 | ``` 34 | 35 | even this: 36 | 37 | 甚至这样用: 38 | 39 | ```swift 40 | "userName".regex("^[a-zA-Z0-9_-]{6,18}$") 41 | ``` 42 | 43 | But my favorites is like this: 44 | 45 | 不过我还是最喜欢这样用: 46 | 47 | ```swift 48 | "userName" =~ "^[a-zA-Z0-9_-]{6,18}$" 49 | ``` 50 | 51 | All of them will return a struct "RegexResult" 52 | 53 | 这些方法都会返回一个结构体"RegexResult“。 54 | 55 | ```swift 56 | public struct RegexResult { 57 | public let text: String 58 | public var matches: [(content:String, range: NSRange, type: NSTextCheckingType)] 59 | public var hasMatch: Bool 60 | public var isCompleteMatch: Bool 61 | } 62 | ``` 63 | 64 | It also prepares some common pattern: Email, Website, IP Address, etc. Welcome for adding more. 65 | 66 | 还准备了一些常用的正则, 如: 邮箱, 网址, IP地址, 等等(欢迎大家来补充)。 67 | 68 | ```swift 69 | "http://www.google.com" =~ RegexPattern.WebSite 70 | ``` 71 | 72 | ## Demo 73 | 74 | I created a demo app for AXRegex. Welcome to create issues when you meet any problems. 75 | 76 | 本人创建了一个范例应用。若遇到任何问题,欢迎提问。 77 | 78 |

79 | Demo 80 |

81 | 82 | ## Requirements 83 | 84 | * Swift 2.0 85 | 86 | ## Installation with CocoaPods 87 | 88 | AXRegex is available through [CocoaPods](http://cocoapods.org). To install 89 | it, simply add the following line to your Podfile: 90 | 91 | ```ruby 92 | platform :ios, '8.0' 93 | pod 'AXRegex', :git => 'https://github.com/ArthurXHK/AXRegex.git' 94 | ``` 95 | 96 | ## Author 97 | 98 | Arthur XU, arthurk.dev@gmail.com 99 | 100 | ## License 101 | 102 | AXRegex is available under the Apache License 2.0. See the LICENSE file for more info. 103 | --------------------------------------------------------------------------------