├── .gitignore ├── .travis.yml ├── .xctool-args ├── LICENSE ├── Lib ├── VerbalExpressions.h └── VerbalExpressions.m ├── Makefile ├── README.md ├── VEVerbalExpressions.podspec ├── VerbalExpressions.xcodeproj ├── project.pbxproj └── xcshareddata │ └── xcschemes │ └── Tests.xcscheme ├── VerbalExpressions ├── AppDelegate.h ├── AppDelegate.m ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── VerbalExpressions-Info.plist ├── VerbalExpressions-Prefix.pch ├── en.lproj │ └── InfoPlist.strings └── main.m ├── VerbalExpressionsTests ├── VerbalExpressionsTests-Info.plist ├── VerbalExpressionsTests.h ├── VerbalExpressionsTests.m └── en.lproj │ └── InfoPlist.strings └── coveralls.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | 20 | # CocoaPods 21 | Pods/ 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | before_install: 3 | - brew update 4 | - brew install xctool 5 | - sudo easy_install cpp-coveralls 6 | script: 7 | - make test 8 | after_success: 9 | - ./coveralls.sh -r ./ -e VerbalExpressions -e VerbalExpressionsTests --verbose -------------------------------------------------------------------------------- /.xctool-args: -------------------------------------------------------------------------------- 1 | [ 2 | "-project", "VerbalExpressions.xcodeproj", 3 | "-scheme", "Tests", 4 | "-configuration", "Debug", 5 | "-sdk", "iphonesimulator", 6 | "-arch", "i386" 7 | ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 kishikawa katsumi (http://kishikawakatsumi.com/) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Lib/VerbalExpressions.h: -------------------------------------------------------------------------------- 1 | // 2 | // VerbalExpressions.h 3 | // VerbalExpressions 4 | // 5 | // Created by kishikawa katsumi on 2013/08/11. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VerbalExpressions : NSObject 12 | 13 | @property (nonatomic, readonly) VerbalExpressions *(^startOfLine)(BOOL enable); 14 | @property (nonatomic, readonly) VerbalExpressions *(^endOfLine)(BOOL enable); 15 | @property (nonatomic, readonly) VerbalExpressions *(^find)(NSString *value); 16 | @property (nonatomic, readonly) VerbalExpressions *(^then)(NSString *value); 17 | @property (nonatomic, readonly) VerbalExpressions *(^maybe)(NSString *value); 18 | @property (nonatomic, readonly) VerbalExpressions *(^anything)(); 19 | @property (nonatomic, readonly) VerbalExpressions *(^anythingBut)(NSString *value); 20 | @property (nonatomic, readonly) VerbalExpressions *(^something)(); 21 | @property (nonatomic, readonly) VerbalExpressions *(^somethingBut)(NSString *value); 22 | @property (nonatomic, readonly) NSString *(^replace)(NSString *source, NSString *value); 23 | @property (nonatomic, readonly) VerbalExpressions *(^lineBreak)(); 24 | @property (nonatomic, readonly) VerbalExpressions *(^br)(); 25 | @property (nonatomic, readonly) VerbalExpressions *(^tab)(); 26 | @property (nonatomic, readonly) VerbalExpressions *(^word)(); 27 | @property (nonatomic, readonly) VerbalExpressions *(^anyOf)(NSString *value); 28 | @property (nonatomic, readonly) VerbalExpressions *(^any)(NSString *value); 29 | @property (nonatomic, readonly) VerbalExpressions *(^range)(NSArray *args); 30 | @property (nonatomic, readonly) VerbalExpressions *(^withAnyCase)(BOOL enable); 31 | @property (nonatomic, readonly) VerbalExpressions *(^searchOneLine)(BOOL enable); 32 | @property (nonatomic, readonly) VerbalExpressions *(^multiple)(NSString *value); 33 | @property (nonatomic, readonly) VerbalExpressions *(^or)(NSString *value); 34 | @property (nonatomic, readonly) VerbalExpressions *(^beginCapture)(); 35 | @property (nonatomic, readonly) VerbalExpressions *(^endCapture)(); 36 | 37 | @property (nonatomic, readonly) BOOL (^test)(NSString *toTest); 38 | 39 | @property (nonatomic, readonly) NSRegularExpression *regularExpression; 40 | @property (nonatomic, readonly) NSRegularExpression *regex; 41 | 42 | + (VerbalExpressions *)instantiate:(void (^)(VerbalExpressions *ve))block; 43 | + (VerbalExpressions *)expressions; 44 | extern VerbalExpressions *VerEx(); 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Lib/VerbalExpressions.m: -------------------------------------------------------------------------------- 1 | // 2 | // VerbalExpressions.m 3 | // VerbalExpressions 4 | // 5 | // Created by kishikawa katsumi on 2013/08/11. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import "VerbalExpressions.h" 10 | 11 | @interface VerbalExpressions () 12 | 13 | @property (nonatomic) NSString *prefixes; 14 | @property (nonatomic) NSString *source; 15 | @property (nonatomic) NSString *suffixes; 16 | @property (nonatomic) NSString *pattern; 17 | @property (nonatomic) NSRegularExpressionOptions modifiers; 18 | 19 | @property (nonatomic, readonly) VerbalExpressions *(^add)(NSString *value); 20 | 21 | @end 22 | 23 | @implementation VerbalExpressions 24 | 25 | + (VerbalExpressions *)instantiate:(void (^)(VerbalExpressions *))block 26 | { 27 | VerbalExpressions *verEx = VerEx(); 28 | if (block) { 29 | block(verEx); 30 | } 31 | 32 | return verEx; 33 | } 34 | 35 | + (VerbalExpressions *)expressions 36 | { 37 | return VerEx(); 38 | } 39 | 40 | VerbalExpressions *VerEx() 41 | { 42 | return [[VerbalExpressions alloc] init]; 43 | } 44 | 45 | - (id)init 46 | { 47 | self = [super init]; 48 | if (self) { 49 | self.prefixes = @""; 50 | self.source = @""; 51 | self.suffixes = @""; 52 | self.pattern = @""; 53 | } 54 | 55 | return self; 56 | } 57 | 58 | - (VerbalExpressions *(^)(BOOL))startOfLine 59 | { 60 | return ^VerbalExpressions *(BOOL enable) { 61 | self.prefixes = enable ? @"^" : @""; 62 | self.add(@""); 63 | return self; 64 | }; 65 | } 66 | 67 | - (VerbalExpressions *(^)(BOOL))endOfLine 68 | { 69 | return ^VerbalExpressions *(BOOL enable) { 70 | self.suffixes = enable ? @"$" : @""; 71 | self.add(@""); 72 | return self; 73 | }; 74 | } 75 | 76 | - (VerbalExpressions *(^)(NSString *))find 77 | { 78 | return ^VerbalExpressions *(NSString *value) { 79 | return self.then(value); 80 | }; 81 | } 82 | 83 | - (VerbalExpressions *(^)(NSString *))then 84 | { 85 | return ^VerbalExpressions *(NSString *value) { 86 | value = [self sanitize:value]; 87 | self.add([NSString stringWithFormat:@"(?:%@)", value]); 88 | return self; 89 | }; 90 | } 91 | 92 | - (VerbalExpressions *(^)(NSString *))maybe 93 | { 94 | return ^VerbalExpressions *(NSString *value) { 95 | value = [self sanitize:value]; 96 | self.add([NSString stringWithFormat:@"(?:%@)?", value]); 97 | return self; 98 | }; 99 | } 100 | 101 | - (VerbalExpressions *(^)())anything 102 | { 103 | return ^VerbalExpressions *() { 104 | self.add(@"(?:.*)"); 105 | return self; 106 | }; 107 | } 108 | 109 | - (VerbalExpressions *(^)(NSString *))anythingBut 110 | { 111 | return ^VerbalExpressions *(NSString *value) { 112 | value = [self sanitize:value]; 113 | self.add([NSString stringWithFormat:@"(?:[^%@]*)", value]); 114 | return self; 115 | }; 116 | } 117 | 118 | - (VerbalExpressions *(^)())something 119 | { 120 | return ^VerbalExpressions *() { 121 | self.add(@"(?:.+)"); 122 | return self; 123 | }; 124 | } 125 | 126 | - (VerbalExpressions *(^)(NSString *))somethingBut 127 | { 128 | return ^VerbalExpressions *(NSString *value) { 129 | value = [self sanitize:value]; 130 | self.add([NSString stringWithFormat:@"(?:[^%@]+)", value]); 131 | return self; 132 | }; 133 | } 134 | 135 | - (NSString *(^)(NSString *, NSString *))replace 136 | { 137 | return ^NSString *(NSString *source, NSString *value) { 138 | self.add(@""); 139 | return [self.regex stringByReplacingMatchesInString:source options:kNilOptions range:NSMakeRange(0, source.length) withTemplate:value]; 140 | }; 141 | } 142 | 143 | - (VerbalExpressions *(^)())lineBreak 144 | { 145 | return ^VerbalExpressions *() { 146 | self.add(@"(?:\\n|(?:\\r\\n))"); 147 | return self; 148 | }; 149 | } 150 | 151 | - (VerbalExpressions *(^)())br 152 | { 153 | return ^VerbalExpressions *() { 154 | self.lineBreak(); 155 | return self; 156 | }; 157 | } 158 | 159 | - (VerbalExpressions *(^)())tab 160 | { 161 | return ^VerbalExpressions *() { 162 | self.add(@"\\t"); 163 | return self; 164 | }; 165 | } 166 | 167 | - (VerbalExpressions *(^)())word 168 | { 169 | return ^VerbalExpressions *() { 170 | self.add(@"\\w+"); 171 | return self; 172 | }; 173 | } 174 | 175 | - (VerbalExpressions *(^)(NSString *))anyOf 176 | { 177 | return ^VerbalExpressions *(NSString *value) { 178 | value = [self sanitize:value]; 179 | self.add([NSString stringWithFormat:@"[%@]", value]); 180 | return self; 181 | }; 182 | } 183 | 184 | - (VerbalExpressions *(^)(NSString *))any 185 | { 186 | return ^VerbalExpressions *(NSString *value) { 187 | self.anyOf(value); 188 | return self; 189 | }; 190 | } 191 | 192 | - (VerbalExpressions *(^)(NSArray *))range 193 | { 194 | return ^VerbalExpressions *(NSArray *args) { 195 | NSString *value = @"["; 196 | for (NSInteger fromIndex = 0; fromIndex < args.count; fromIndex += 2) { 197 | NSInteger toIndex = fromIndex + 1; 198 | if (args.count <= toIndex) { 199 | break; 200 | } 201 | 202 | NSString *from = [self sanitize:args[fromIndex]]; 203 | NSString *to = [self sanitize:args[toIndex]]; 204 | value = [value stringByAppendingFormat:@"%@-%@", from, to]; 205 | } 206 | 207 | value = [value stringByAppendingString:@"]"]; 208 | 209 | self.add(value); 210 | return self; 211 | }; 212 | } 213 | 214 | - (VerbalExpressions *(^)(BOOL))withAnyCase 215 | { 216 | return ^VerbalExpressions *(BOOL enable) { 217 | if (enable) { 218 | self.addModifier('i'); 219 | } else { 220 | self.removeModifier('i'); 221 | } 222 | self.add(@""); 223 | return self; 224 | }; 225 | } 226 | 227 | - (VerbalExpressions *(^)(BOOL))searchOneLine 228 | { 229 | return ^VerbalExpressions *(BOOL enable) { 230 | if (enable) { 231 | self.removeModifier('m'); 232 | } else { 233 | self.addModifier('m'); 234 | } 235 | self.add(@""); 236 | return self; 237 | }; 238 | } 239 | 240 | - (VerbalExpressions *(^)(NSString *))multiple 241 | { 242 | return ^VerbalExpressions *(NSString *value) { 243 | value = [self sanitize:value]; 244 | NSString *suffix = [value substringFromIndex:value.length - 1]; 245 | if (![suffix isEqualToString:@"*"] && ![suffix isEqualToString:@"+"]) { 246 | value = [value stringByAppendingString:@"+"]; 247 | } 248 | self.add(value); 249 | return self; 250 | }; 251 | } 252 | 253 | - (VerbalExpressions *(^)(NSString *))or 254 | { 255 | return ^VerbalExpressions *(NSString *value) { 256 | if ([self.prefixes rangeOfString:@"("].location == NSNotFound) { 257 | self.prefixes = [self.prefixes stringByAppendingString:@"(?:"]; 258 | } 259 | if ([self.suffixes rangeOfString:@")"].location == NSNotFound) { 260 | self.suffixes = [self.suffixes stringByAppendingString:@")"]; 261 | } 262 | self.add(@")|(?:"); 263 | if (value) { 264 | self.then(value); 265 | } 266 | return self; 267 | }; 268 | } 269 | 270 | - (VerbalExpressions *(^)())beginCapture 271 | { 272 | return ^VerbalExpressions *() { 273 | self.suffixes = [self.suffixes stringByAppendingString:@")"]; 274 | self.add(@"("); 275 | return self; 276 | }; 277 | } 278 | 279 | - (VerbalExpressions *(^)())endCapture 280 | { 281 | return ^VerbalExpressions *() { 282 | self.suffixes = [self.suffixes substringToIndex:self.suffixes.length - 1]; 283 | self.add(@")"); 284 | return self; 285 | }; 286 | } 287 | 288 | - (BOOL(^)(NSString *))test 289 | { 290 | return ^BOOL (NSString *toTest) { 291 | self.add(@""); 292 | 293 | NSRegularExpression *regex = self.regularExpression; 294 | NSUInteger matches = [regex numberOfMatchesInString:toTest options:kNilOptions range:NSMakeRange(0, toTest.length)]; 295 | 296 | return matches > 0; 297 | }; 298 | } 299 | 300 | - (NSRegularExpression *)regularExpression 301 | { 302 | NSError *error = nil; 303 | NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:self.pattern 304 | options:self.modifiers 305 | error:&error]; 306 | if (error) { 307 | return nil; 308 | } 309 | 310 | return regex; 311 | } 312 | 313 | - (NSRegularExpression *)regex 314 | { 315 | return self.regularExpression; 316 | } 317 | 318 | - (NSString *)description 319 | { 320 | self.add(@""); 321 | return self.regularExpression.pattern; 322 | } 323 | 324 | #pragma mark praivate methods 325 | 326 | - (NSString *)sanitize:(NSString *)value 327 | { 328 | if (!value) { 329 | return nil; 330 | } 331 | return [NSRegularExpression escapedPatternForString:value]; 332 | } 333 | 334 | - (VerbalExpressions *(^)(NSString *))add 335 | { 336 | return ^VerbalExpressions *(NSString *value) { 337 | self.source = self.source ? [self.source stringByAppendingString:value] : value; 338 | if (self.source) { 339 | self.pattern = [NSString stringWithFormat:@"%@%@%@", self.prefixes, self.source, self.suffixes]; 340 | } 341 | 342 | return self; 343 | }; 344 | } 345 | 346 | - (VerbalExpressions *(^)(unichar))addModifier 347 | { 348 | return ^VerbalExpressions *(unichar modifier) { 349 | switch (modifier) { 350 | case 'd': // UREGEX_UNIX_LINES 351 | self.modifiers |= NSRegularExpressionUseUnixLineSeparators; 352 | break; 353 | case 'i': // UREGEX_CASE_INSENSITIVE 354 | self.modifiers |= NSRegularExpressionCaseInsensitive; 355 | break; 356 | case 'x': // UREGEX_COMMENTS 357 | self.modifiers |= NSRegularExpressionAllowCommentsAndWhitespace; 358 | break; 359 | case 'm': // UREGEX_MULTILINE 360 | self.modifiers |= NSRegularExpressionAnchorsMatchLines; 361 | break; 362 | case 's': // UREGEX_DOTALL 363 | self.modifiers |= NSRegularExpressionDotMatchesLineSeparators; 364 | break; 365 | case 'u': // UREGEX_UWORD 366 | self.modifiers |= NSRegularExpressionUseUnicodeWordBoundaries; 367 | break; 368 | case 'U': // UREGEX_LITERAL 369 | self.modifiers |= NSRegularExpressionIgnoreMetacharacters; 370 | break; 371 | default: 372 | break; 373 | } 374 | 375 | self.add(@""); 376 | return self; 377 | }; 378 | } 379 | 380 | - (VerbalExpressions *(^)(unichar))removeModifier 381 | { 382 | return ^VerbalExpressions *(unichar modifier) { 383 | switch (modifier) { 384 | case 'd': // UREGEX_UNIX_LINES 385 | self.modifiers ^= NSRegularExpressionUseUnixLineSeparators; 386 | break; 387 | case 'i': // UREGEX_CASE_INSENSITIVE 388 | self.modifiers ^= NSRegularExpressionCaseInsensitive; 389 | break; 390 | case 'x': // UREGEX_COMMENTS 391 | self.modifiers ^= NSRegularExpressionAllowCommentsAndWhitespace; 392 | break; 393 | case 'm': // UREGEX_MULTILINE 394 | self.modifiers ^= NSRegularExpressionAnchorsMatchLines; 395 | break; 396 | case 's': // UREGEX_DOTALL 397 | self.modifiers ^= NSRegularExpressionDotMatchesLineSeparators; 398 | break; 399 | case 'u': // UREGEX_UWORD 400 | self.modifiers ^= NSRegularExpressionUseUnicodeWordBoundaries; 401 | break; 402 | case 'U': // UREGEX_LITERAL 403 | self.modifiers ^= NSRegularExpressionIgnoreMetacharacters; 404 | break; 405 | default: 406 | break; 407 | } 408 | 409 | self.add(@""); 410 | return self; 411 | }; 412 | } 413 | 414 | @end 415 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | xctool \ 3 | clean build test \ 4 | ONLY_ACTIVE_ARCH=NO \ 5 | TEST_AFTER_BUILD=YES \ 6 | GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES \ 7 | GCC_GENERATE_TEST_COVERAGE_FILES=YES -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ObjectiveCVerbalExpressions 2 | ===================== 3 | ![version](http://cocoapod-badges.herokuapp.com/v/VEVerbalExpressions/badge.svg) 4 | ![platform](http://cocoapod-badges.herokuapp.com/p/VEVerbalExpressions/badge.svg) 5 | [![Build Status](https://travis-ci.org/kishikawakatsumi/ObjectiveCVerbalExpressions.png?branch=master)](https://travis-ci.org/kishikawakatsumi/ObjectiveCVerbalExpressions) 6 | [![Coverage Status](https://coveralls.io/repos/kishikawakatsumi/ObjectiveCVerbalExpressions/badge.png?branch=master)](https://coveralls.io/r/kishikawakatsumi/ObjectiveCVerbalExpressions?branch=master) 7 | 8 | ## Objective-C Regular Expressions made easy 9 | ObjectiveCVerbalExpressions is a Objective-C library that helps to construct difficult regular expressions - ported from the awesome JavaScript [VerbalExpressions](https://github.com/jehna/VerbalExpressions). 10 | 11 | ## Installation 12 | ### From [Cocoapods](http://cocoapods.org/) 13 | `pod 'VEVerbalExpressions'` 14 | 15 | ### From source 16 | Drags `VerbalExpressions.h` and `VerbalExpressions.m` into your projects and `import "VerbalExpressions.h"` 17 | 18 | ## Examples 19 | 20 | Here's a couple of simple examples to give an idea of how VerbalExpressions works: 21 | 22 | ### Testing if we have a valid URL 23 | 24 | ```objc 25 | // Create an example of how to test for correctly formed URLs 26 | VerbalExpressions *tester = VerEx() 27 | .startOfLine(YES) 28 | .then(@"http") 29 | .maybe(@"s") 30 | .then(@"://") 31 | .maybe(@"www") 32 | .anythingBut(@" ") 33 | .endOfLine(YES); 34 | 35 | // Create an example URL 36 | NSString *testMe = @"https://www.google.com"; 37 | 38 | // Use test() method 39 | if (tester.test(testMe)) { 40 | NSLog(@"%@", @"We have a correct URL"); // This output will fire 41 | } else { 42 | NSLog(@"%@", @"The URL is incorrect"); 43 | } 44 | 45 | NSLog(@"%@", tester); // Ouputs the actual expression used: "^(http)(s)?(:�_/�_/)(www)?([^ ]*)$" 46 | ``` 47 | 48 | ### Replacing strings 49 | 50 | ```objc 51 | NSString *replaceMe = @"Replace bird with a duck"; 52 | 53 | // Create an expression that seeks for word "bird" 54 | VerbalExpressions *verEx = VerEx().find(@"bird"); 55 | 56 | // Execute the expression like a normal RegExp object 57 | NSString *result = verEx.replace(replaceMe, @"duck" ); 58 | 59 | NSLog(@"%@", result); // Outputs "Replace duck with a duck" 60 | ``` 61 | 62 | ### Shorthand for string replace: 63 | 64 | ```objc 65 | NSString *result2 = VerEx().find(@"red").replace(@"We have a red house", @"blue"); 66 | 67 | NSLog(@"%@", result2); // Outputs "We have a blue house" 68 | ``` 69 | 70 | ## API documentation 71 | 72 | I haven't added much documentation to this repo yet, but you can find the documentation for the original JavaScript repo on their [wiki](https://github.com/jehna/VerbalExpressions/wiki). Most of the methods have been ported as of v0.1.0 of the JavaScript repo. Just be sure to use the syntax explained above rather than the dot notation :) 73 | 74 | ## Contributions 75 | Clone the repo and fork! 76 | Pull requests are warmly welcomed! 77 | 78 | ## Issues 79 | - I haven't yet ported the `stopAtFirst` method. 80 | 81 | ## Thanks! 82 | Thank you to @jehna for coming up with the awesome original idea! 83 | 84 | ## Other implementations 85 | You can view all implementations on [VerbalExpressions.github.io](http://VerbalExpressions.github.io) 86 | -------------------------------------------------------------------------------- /VEVerbalExpressions.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "VEVerbalExpressions" 3 | s.version = "0.1.2" 4 | s.summary = "Objective-C Regular Expressions made easy" 5 | s.homepage = "https://github.com/VerbalExpressions/ObjectiveCVerbalExpressions" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = { "kishikawakatsumi" => "kishikawakatsumi@mac.com" } 8 | s.authors = { "kishikawakatsumi" => "kishikawakatsumi@mac.com" } 9 | s.source = { :git => "https://github.com/VerbalExpressions/ObjectiveCVerbalExpressions.git", :tag => "v0.1.2" } 10 | s.ios.deployment_target = "4.0" 11 | s.osx.deployment_target = "10.7" 12 | s.source_files = "Lib/*" 13 | s.requires_arc = true 14 | end 15 | -------------------------------------------------------------------------------- /VerbalExpressions.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1481B63917B7FE7200EA9DA4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1481B63817B7FE7200EA9DA4 /* UIKit.framework */; }; 11 | 1481B63B17B7FE7200EA9DA4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1481B63A17B7FE7200EA9DA4 /* Foundation.framework */; }; 12 | 1481B63D17B7FE7200EA9DA4 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1481B63C17B7FE7200EA9DA4 /* CoreGraphics.framework */; }; 13 | 1481B64317B7FE7200EA9DA4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1481B64117B7FE7200EA9DA4 /* InfoPlist.strings */; }; 14 | 1481B64517B7FE7200EA9DA4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1481B64417B7FE7200EA9DA4 /* main.m */; }; 15 | 1481B64917B7FE7200EA9DA4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1481B64817B7FE7200EA9DA4 /* AppDelegate.m */; }; 16 | 1481B65717B7FE7300EA9DA4 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1481B65617B7FE7300EA9DA4 /* SenTestingKit.framework */; }; 17 | 1481B65817B7FE7300EA9DA4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1481B63817B7FE7200EA9DA4 /* UIKit.framework */; }; 18 | 1481B65917B7FE7300EA9DA4 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1481B63A17B7FE7200EA9DA4 /* Foundation.framework */; }; 19 | 1481B66117B7FE7300EA9DA4 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 1481B65F17B7FE7300EA9DA4 /* InfoPlist.strings */; }; 20 | 1481B66417B7FE7300EA9DA4 /* VerbalExpressionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1481B66317B7FE7300EA9DA4 /* VerbalExpressionsTests.m */; }; 21 | 1481B6BE17B8127400EA9DA4 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1481B6BB17B8127400EA9DA4 /* Default.png */; }; 22 | 1481B6BF17B8127400EA9DA4 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1481B6BC17B8127400EA9DA4 /* Default@2x.png */; }; 23 | 1481B6C017B8127400EA9DA4 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1481B6BD17B8127400EA9DA4 /* Default-568h@2x.png */; }; 24 | 1481B6C317B8AEDA00EA9DA4 /* VerbalExpressions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1481B6C217B8AEDA00EA9DA4 /* VerbalExpressions.m */; }; 25 | 1481B6C417B8AEDA00EA9DA4 /* VerbalExpressions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1481B6C217B8AEDA00EA9DA4 /* VerbalExpressions.m */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | 1481B65A17B7FE7300EA9DA4 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 1481B62D17B7FE7200EA9DA4 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 1481B63417B7FE7200EA9DA4; 34 | remoteInfo = VerbalExpressions; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 1481B63517B7FE7200EA9DA4 /* VerbalExpressions.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VerbalExpressions.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 1481B63817B7FE7200EA9DA4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 41 | 1481B63A17B7FE7200EA9DA4 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 42 | 1481B63C17B7FE7200EA9DA4 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 43 | 1481B64017B7FE7200EA9DA4 /* VerbalExpressions-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "VerbalExpressions-Info.plist"; sourceTree = ""; }; 44 | 1481B64217B7FE7200EA9DA4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 45 | 1481B64417B7FE7200EA9DA4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 46 | 1481B64617B7FE7200EA9DA4 /* VerbalExpressions-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "VerbalExpressions-Prefix.pch"; sourceTree = ""; }; 47 | 1481B64717B7FE7200EA9DA4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 48 | 1481B64817B7FE7200EA9DA4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 49 | 1481B65517B7FE7300EA9DA4 /* VerbalExpressionsTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VerbalExpressionsTests.octest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 1481B65617B7FE7300EA9DA4 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 51 | 1481B65E17B7FE7300EA9DA4 /* VerbalExpressionsTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "VerbalExpressionsTests-Info.plist"; sourceTree = ""; }; 52 | 1481B66017B7FE7300EA9DA4 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 53 | 1481B66217B7FE7300EA9DA4 /* VerbalExpressionsTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VerbalExpressionsTests.h; sourceTree = ""; }; 54 | 1481B66317B7FE7300EA9DA4 /* VerbalExpressionsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VerbalExpressionsTests.m; sourceTree = ""; }; 55 | 1481B6BB17B8127400EA9DA4 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 56 | 1481B6BC17B8127400EA9DA4 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 57 | 1481B6BD17B8127400EA9DA4 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 58 | 1481B6C117B8AEDA00EA9DA4 /* VerbalExpressions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VerbalExpressions.h; path = Lib/VerbalExpressions.h; sourceTree = SOURCE_ROOT; }; 59 | 1481B6C217B8AEDA00EA9DA4 /* VerbalExpressions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VerbalExpressions.m; path = Lib/VerbalExpressions.m; sourceTree = SOURCE_ROOT; }; 60 | /* End PBXFileReference section */ 61 | 62 | /* Begin PBXFrameworksBuildPhase section */ 63 | 1481B63217B7FE7200EA9DA4 /* Frameworks */ = { 64 | isa = PBXFrameworksBuildPhase; 65 | buildActionMask = 2147483647; 66 | files = ( 67 | 1481B63917B7FE7200EA9DA4 /* UIKit.framework in Frameworks */, 68 | 1481B63B17B7FE7200EA9DA4 /* Foundation.framework in Frameworks */, 69 | 1481B63D17B7FE7200EA9DA4 /* CoreGraphics.framework in Frameworks */, 70 | ); 71 | runOnlyForDeploymentPostprocessing = 0; 72 | }; 73 | 1481B65117B7FE7300EA9DA4 /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | 1481B65717B7FE7300EA9DA4 /* SenTestingKit.framework in Frameworks */, 78 | 1481B65817B7FE7300EA9DA4 /* UIKit.framework in Frameworks */, 79 | 1481B65917B7FE7300EA9DA4 /* Foundation.framework in Frameworks */, 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | /* End PBXFrameworksBuildPhase section */ 84 | 85 | /* Begin PBXGroup section */ 86 | 1481B62C17B7FE7200EA9DA4 = { 87 | isa = PBXGroup; 88 | children = ( 89 | 1481B63E17B7FE7200EA9DA4 /* VerbalExpressions */, 90 | 1481B65C17B7FE7300EA9DA4 /* VerbalExpressionsTests */, 91 | 1481B63717B7FE7200EA9DA4 /* Frameworks */, 92 | 1481B63617B7FE7200EA9DA4 /* Products */, 93 | ); 94 | sourceTree = ""; 95 | }; 96 | 1481B63617B7FE7200EA9DA4 /* Products */ = { 97 | isa = PBXGroup; 98 | children = ( 99 | 1481B63517B7FE7200EA9DA4 /* VerbalExpressions.app */, 100 | 1481B65517B7FE7300EA9DA4 /* VerbalExpressionsTests.octest */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 1481B63717B7FE7200EA9DA4 /* Frameworks */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 1481B63817B7FE7200EA9DA4 /* UIKit.framework */, 109 | 1481B63A17B7FE7200EA9DA4 /* Foundation.framework */, 110 | 1481B63C17B7FE7200EA9DA4 /* CoreGraphics.framework */, 111 | 1481B65617B7FE7300EA9DA4 /* SenTestingKit.framework */, 112 | ); 113 | name = Frameworks; 114 | sourceTree = ""; 115 | }; 116 | 1481B63E17B7FE7200EA9DA4 /* VerbalExpressions */ = { 117 | isa = PBXGroup; 118 | children = ( 119 | 1481B6C517B8AEDF00EA9DA4 /* Lib */, 120 | 1481B6C617B8AEEF00EA9DA4 /* Sample */, 121 | 1481B63F17B7FE7200EA9DA4 /* Supporting Files */, 122 | ); 123 | path = VerbalExpressions; 124 | sourceTree = ""; 125 | }; 126 | 1481B63F17B7FE7200EA9DA4 /* Supporting Files */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | 1481B64017B7FE7200EA9DA4 /* VerbalExpressions-Info.plist */, 130 | 1481B64117B7FE7200EA9DA4 /* InfoPlist.strings */, 131 | 1481B64417B7FE7200EA9DA4 /* main.m */, 132 | 1481B64617B7FE7200EA9DA4 /* VerbalExpressions-Prefix.pch */, 133 | 1481B6BB17B8127400EA9DA4 /* Default.png */, 134 | 1481B6BC17B8127400EA9DA4 /* Default@2x.png */, 135 | 1481B6BD17B8127400EA9DA4 /* Default-568h@2x.png */, 136 | ); 137 | name = "Supporting Files"; 138 | sourceTree = ""; 139 | }; 140 | 1481B65C17B7FE7300EA9DA4 /* VerbalExpressionsTests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 1481B66217B7FE7300EA9DA4 /* VerbalExpressionsTests.h */, 144 | 1481B66317B7FE7300EA9DA4 /* VerbalExpressionsTests.m */, 145 | 1481B65D17B7FE7300EA9DA4 /* Supporting Files */, 146 | ); 147 | path = VerbalExpressionsTests; 148 | sourceTree = ""; 149 | }; 150 | 1481B65D17B7FE7300EA9DA4 /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 1481B65E17B7FE7300EA9DA4 /* VerbalExpressionsTests-Info.plist */, 154 | 1481B65F17B7FE7300EA9DA4 /* InfoPlist.strings */, 155 | ); 156 | name = "Supporting Files"; 157 | sourceTree = ""; 158 | }; 159 | 1481B6C517B8AEDF00EA9DA4 /* Lib */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 1481B6C117B8AEDA00EA9DA4 /* VerbalExpressions.h */, 163 | 1481B6C217B8AEDA00EA9DA4 /* VerbalExpressions.m */, 164 | ); 165 | name = Lib; 166 | sourceTree = ""; 167 | }; 168 | 1481B6C617B8AEEF00EA9DA4 /* Sample */ = { 169 | isa = PBXGroup; 170 | children = ( 171 | 1481B64717B7FE7200EA9DA4 /* AppDelegate.h */, 172 | 1481B64817B7FE7200EA9DA4 /* AppDelegate.m */, 173 | ); 174 | name = Sample; 175 | sourceTree = ""; 176 | }; 177 | /* End PBXGroup section */ 178 | 179 | /* Begin PBXNativeTarget section */ 180 | 1481B63417B7FE7200EA9DA4 /* VerbalExpressions */ = { 181 | isa = PBXNativeTarget; 182 | buildConfigurationList = 1481B66717B7FE7300EA9DA4 /* Build configuration list for PBXNativeTarget "VerbalExpressions" */; 183 | buildPhases = ( 184 | 1481B63117B7FE7200EA9DA4 /* Sources */, 185 | 1481B63217B7FE7200EA9DA4 /* Frameworks */, 186 | 1481B63317B7FE7200EA9DA4 /* Resources */, 187 | ); 188 | buildRules = ( 189 | ); 190 | dependencies = ( 191 | ); 192 | name = VerbalExpressions; 193 | productName = VerbalExpressions; 194 | productReference = 1481B63517B7FE7200EA9DA4 /* VerbalExpressions.app */; 195 | productType = "com.apple.product-type.application"; 196 | }; 197 | 1481B65417B7FE7300EA9DA4 /* VerbalExpressionsTests */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = 1481B66A17B7FE7300EA9DA4 /* Build configuration list for PBXNativeTarget "VerbalExpressionsTests" */; 200 | buildPhases = ( 201 | 1481B65017B7FE7300EA9DA4 /* Sources */, 202 | 1481B65117B7FE7300EA9DA4 /* Frameworks */, 203 | 1481B65217B7FE7300EA9DA4 /* Resources */, 204 | 1481B65317B7FE7300EA9DA4 /* ShellScript */, 205 | ); 206 | buildRules = ( 207 | ); 208 | dependencies = ( 209 | 1481B65B17B7FE7300EA9DA4 /* PBXTargetDependency */, 210 | ); 211 | name = VerbalExpressionsTests; 212 | productName = VerbalExpressionsTests; 213 | productReference = 1481B65517B7FE7300EA9DA4 /* VerbalExpressionsTests.octest */; 214 | productType = "com.apple.product-type.bundle"; 215 | }; 216 | /* End PBXNativeTarget section */ 217 | 218 | /* Begin PBXProject section */ 219 | 1481B62D17B7FE7200EA9DA4 /* Project object */ = { 220 | isa = PBXProject; 221 | attributes = { 222 | LastUpgradeCheck = 0460; 223 | ORGANIZATIONNAME = "kishikawa katsumi"; 224 | }; 225 | buildConfigurationList = 1481B63017B7FE7200EA9DA4 /* Build configuration list for PBXProject "VerbalExpressions" */; 226 | compatibilityVersion = "Xcode 3.2"; 227 | developmentRegion = English; 228 | hasScannedForEncodings = 0; 229 | knownRegions = ( 230 | en, 231 | ); 232 | mainGroup = 1481B62C17B7FE7200EA9DA4; 233 | productRefGroup = 1481B63617B7FE7200EA9DA4 /* Products */; 234 | projectDirPath = ""; 235 | projectRoot = ""; 236 | targets = ( 237 | 1481B63417B7FE7200EA9DA4 /* VerbalExpressions */, 238 | 1481B65417B7FE7300EA9DA4 /* VerbalExpressionsTests */, 239 | ); 240 | }; 241 | /* End PBXProject section */ 242 | 243 | /* Begin PBXResourcesBuildPhase section */ 244 | 1481B63317B7FE7200EA9DA4 /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | 1481B64317B7FE7200EA9DA4 /* InfoPlist.strings in Resources */, 249 | 1481B6BE17B8127400EA9DA4 /* Default.png in Resources */, 250 | 1481B6BF17B8127400EA9DA4 /* Default@2x.png in Resources */, 251 | 1481B6C017B8127400EA9DA4 /* Default-568h@2x.png in Resources */, 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | 1481B65217B7FE7300EA9DA4 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | 1481B66117B7FE7300EA9DA4 /* InfoPlist.strings in Resources */, 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXShellScriptBuildPhase section */ 266 | 1481B65317B7FE7300EA9DA4 /* ShellScript */ = { 267 | isa = PBXShellScriptBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | inputPaths = ( 272 | ); 273 | outputPaths = ( 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | shellPath = /bin/sh; 277 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 278 | }; 279 | /* End PBXShellScriptBuildPhase section */ 280 | 281 | /* Begin PBXSourcesBuildPhase section */ 282 | 1481B63117B7FE7200EA9DA4 /* Sources */ = { 283 | isa = PBXSourcesBuildPhase; 284 | buildActionMask = 2147483647; 285 | files = ( 286 | 1481B64517B7FE7200EA9DA4 /* main.m in Sources */, 287 | 1481B64917B7FE7200EA9DA4 /* AppDelegate.m in Sources */, 288 | 1481B6C317B8AEDA00EA9DA4 /* VerbalExpressions.m in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | 1481B65017B7FE7300EA9DA4 /* Sources */ = { 293 | isa = PBXSourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | 1481B6C417B8AEDA00EA9DA4 /* VerbalExpressions.m in Sources */, 297 | 1481B66417B7FE7300EA9DA4 /* VerbalExpressionsTests.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXTargetDependency section */ 304 | 1481B65B17B7FE7300EA9DA4 /* PBXTargetDependency */ = { 305 | isa = PBXTargetDependency; 306 | target = 1481B63417B7FE7200EA9DA4 /* VerbalExpressions */; 307 | targetProxy = 1481B65A17B7FE7300EA9DA4 /* PBXContainerItemProxy */; 308 | }; 309 | /* End PBXTargetDependency section */ 310 | 311 | /* Begin PBXVariantGroup section */ 312 | 1481B64117B7FE7200EA9DA4 /* InfoPlist.strings */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 1481B64217B7FE7200EA9DA4 /* en */, 316 | ); 317 | name = InfoPlist.strings; 318 | sourceTree = ""; 319 | }; 320 | 1481B65F17B7FE7300EA9DA4 /* InfoPlist.strings */ = { 321 | isa = PBXVariantGroup; 322 | children = ( 323 | 1481B66017B7FE7300EA9DA4 /* en */, 324 | ); 325 | name = InfoPlist.strings; 326 | sourceTree = ""; 327 | }; 328 | /* End PBXVariantGroup section */ 329 | 330 | /* Begin XCBuildConfiguration section */ 331 | 1481B66517B7FE7300EA9DA4 /* Debug */ = { 332 | isa = XCBuildConfiguration; 333 | buildSettings = { 334 | ALWAYS_SEARCH_USER_PATHS = NO; 335 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 336 | CLANG_CXX_LIBRARY = "libc++"; 337 | CLANG_ENABLE_OBJC_ARC = YES; 338 | CLANG_WARN_CONSTANT_CONVERSION = YES; 339 | CLANG_WARN_EMPTY_BODY = YES; 340 | CLANG_WARN_ENUM_CONVERSION = YES; 341 | CLANG_WARN_INT_CONVERSION = YES; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 344 | COPY_PHASE_STRIP = NO; 345 | GCC_C_LANGUAGE_STANDARD = gnu99; 346 | GCC_DYNAMIC_NO_PIC = NO; 347 | GCC_OPTIMIZATION_LEVEL = 0; 348 | GCC_PREPROCESSOR_DEFINITIONS = ( 349 | "DEBUG=1", 350 | "$(inherited)", 351 | ); 352 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 353 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 354 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 355 | GCC_WARN_UNUSED_VARIABLE = YES; 356 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 357 | ONLY_ACTIVE_ARCH = YES; 358 | SDKROOT = iphoneos; 359 | }; 360 | name = Debug; 361 | }; 362 | 1481B66617B7FE7300EA9DA4 /* Release */ = { 363 | isa = XCBuildConfiguration; 364 | buildSettings = { 365 | ALWAYS_SEARCH_USER_PATHS = NO; 366 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 367 | CLANG_CXX_LIBRARY = "libc++"; 368 | CLANG_ENABLE_OBJC_ARC = YES; 369 | CLANG_WARN_CONSTANT_CONVERSION = YES; 370 | CLANG_WARN_EMPTY_BODY = YES; 371 | CLANG_WARN_ENUM_CONVERSION = YES; 372 | CLANG_WARN_INT_CONVERSION = YES; 373 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 374 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 375 | COPY_PHASE_STRIP = YES; 376 | GCC_C_LANGUAGE_STANDARD = gnu99; 377 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 378 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 379 | GCC_WARN_UNUSED_VARIABLE = YES; 380 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 381 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 382 | SDKROOT = iphoneos; 383 | VALIDATE_PRODUCT = YES; 384 | }; 385 | name = Release; 386 | }; 387 | 1481B66817B7FE7300EA9DA4 /* Debug */ = { 388 | isa = XCBuildConfiguration; 389 | buildSettings = { 390 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 391 | GCC_PREFIX_HEADER = "VerbalExpressions/VerbalExpressions-Prefix.pch"; 392 | INFOPLIST_FILE = "VerbalExpressions/VerbalExpressions-Info.plist"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | WRAPPER_EXTENSION = app; 395 | }; 396 | name = Debug; 397 | }; 398 | 1481B66917B7FE7300EA9DA4 /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 402 | GCC_PREFIX_HEADER = "VerbalExpressions/VerbalExpressions-Prefix.pch"; 403 | INFOPLIST_FILE = "VerbalExpressions/VerbalExpressions-Info.plist"; 404 | PRODUCT_NAME = "$(TARGET_NAME)"; 405 | WRAPPER_EXTENSION = app; 406 | }; 407 | name = Release; 408 | }; 409 | 1481B66B17B7FE7300EA9DA4 /* Debug */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/VerbalExpressions.app/VerbalExpressions"; 413 | FRAMEWORK_SEARCH_PATHS = ( 414 | "\"$(SDKROOT)/Developer/Library/Frameworks\"", 415 | "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", 416 | ); 417 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 418 | GCC_PREFIX_HEADER = "VerbalExpressions/VerbalExpressions-Prefix.pch"; 419 | INFOPLIST_FILE = "VerbalExpressionsTests/VerbalExpressionsTests-Info.plist"; 420 | PRODUCT_NAME = "$(TARGET_NAME)"; 421 | TEST_HOST = "$(BUNDLE_LOADER)"; 422 | WRAPPER_EXTENSION = octest; 423 | }; 424 | name = Debug; 425 | }; 426 | 1481B66C17B7FE7300EA9DA4 /* Release */ = { 427 | isa = XCBuildConfiguration; 428 | buildSettings = { 429 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/VerbalExpressions.app/VerbalExpressions"; 430 | FRAMEWORK_SEARCH_PATHS = ( 431 | "\"$(SDKROOT)/Developer/Library/Frameworks\"", 432 | "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", 433 | ); 434 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 435 | GCC_PREFIX_HEADER = "VerbalExpressions/VerbalExpressions-Prefix.pch"; 436 | INFOPLIST_FILE = "VerbalExpressionsTests/VerbalExpressionsTests-Info.plist"; 437 | PRODUCT_NAME = "$(TARGET_NAME)"; 438 | TEST_HOST = "$(BUNDLE_LOADER)"; 439 | WRAPPER_EXTENSION = octest; 440 | }; 441 | name = Release; 442 | }; 443 | /* End XCBuildConfiguration section */ 444 | 445 | /* Begin XCConfigurationList section */ 446 | 1481B63017B7FE7200EA9DA4 /* Build configuration list for PBXProject "VerbalExpressions" */ = { 447 | isa = XCConfigurationList; 448 | buildConfigurations = ( 449 | 1481B66517B7FE7300EA9DA4 /* Debug */, 450 | 1481B66617B7FE7300EA9DA4 /* Release */, 451 | ); 452 | defaultConfigurationIsVisible = 0; 453 | defaultConfigurationName = Release; 454 | }; 455 | 1481B66717B7FE7300EA9DA4 /* Build configuration list for PBXNativeTarget "VerbalExpressions" */ = { 456 | isa = XCConfigurationList; 457 | buildConfigurations = ( 458 | 1481B66817B7FE7300EA9DA4 /* Debug */, 459 | 1481B66917B7FE7300EA9DA4 /* Release */, 460 | ); 461 | defaultConfigurationIsVisible = 0; 462 | defaultConfigurationName = Release; 463 | }; 464 | 1481B66A17B7FE7300EA9DA4 /* Build configuration list for PBXNativeTarget "VerbalExpressionsTests" */ = { 465 | isa = XCConfigurationList; 466 | buildConfigurations = ( 467 | 1481B66B17B7FE7300EA9DA4 /* Debug */, 468 | 1481B66C17B7FE7300EA9DA4 /* Release */, 469 | ); 470 | defaultConfigurationIsVisible = 0; 471 | defaultConfigurationName = Release; 472 | }; 473 | /* End XCConfigurationList section */ 474 | }; 475 | rootObject = 1481B62D17B7FE7200EA9DA4 /* Project object */; 476 | } 477 | -------------------------------------------------------------------------------- /VerbalExpressions.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /VerbalExpressions/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // VerbalExpressions 4 | // 5 | // Created by kishikawa katsumi on 2013/08/12. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /VerbalExpressions/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // VerbalExpressions 4 | // 5 | // Created by kishikawa katsumi on 2013/08/12. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "VerbalExpressions.h" 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | /* 17 | * Testing if we have a valid URL 18 | */ 19 | // Create an example of how to test for correctly formed URLs 20 | VerbalExpressions *tester = VerEx() 21 | .startOfLine(YES) 22 | .then(@"http") 23 | .maybe(@"s") 24 | .then(@"://") 25 | .maybe(@"www") 26 | .anythingBut(@" ") 27 | .endOfLine(YES); 28 | 29 | // Create an example URL 30 | NSString *testMe = @"https://www.google.com"; 31 | 32 | // Use test() method 33 | if (tester.test(testMe)) { 34 | NSLog(@"%@", @"We have a correct URL"); // This output will fire 35 | } else { 36 | NSLog(@"%@", @"The URL is incorrect"); 37 | } 38 | 39 | NSLog(@"%@", tester); // Ouputs the actual expression used: "^(http)(s)?(:\/\/)(www)?([^ ]*)$" 40 | 41 | /* 42 | * Replacing strings 43 | */ 44 | // Create a test string 45 | NSString *replaceMe = @"Replace bird with a duck"; 46 | 47 | // Create an expression that seeks for word "bird" 48 | VerbalExpressions *verEx = VerEx().find(@"bird"); 49 | 50 | // Execute the expression like a normal RegExp object 51 | NSString *result1 = verEx.replace(replaceMe, @"duck" ); 52 | 53 | NSLog(@"%@", result1); // Outputs "Replace duck with a duck" 54 | 55 | /* 56 | * Shorthand for string replace: 57 | */ 58 | NSString *result2 = VerEx().find(@"red").replace(@"We have a red house", @"blue"); 59 | 60 | NSLog(@"%@", result2); // Outputs "We have a blue house" 61 | 62 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 63 | self.window.backgroundColor = [UIColor whiteColor]; 64 | [self.window makeKeyAndVisible]; 65 | 66 | return YES; 67 | } 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /VerbalExpressions/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerbalExpressions/ObjectiveCVerbalExpressions/352177fec4d5cc2eb561bcdf2935bd59783eaabc/VerbalExpressions/Default-568h@2x.png -------------------------------------------------------------------------------- /VerbalExpressions/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerbalExpressions/ObjectiveCVerbalExpressions/352177fec4d5cc2eb561bcdf2935bd59783eaabc/VerbalExpressions/Default.png -------------------------------------------------------------------------------- /VerbalExpressions/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VerbalExpressions/ObjectiveCVerbalExpressions/352177fec4d5cc2eb561bcdf2935bd59783eaabc/VerbalExpressions/Default@2x.png -------------------------------------------------------------------------------- /VerbalExpressions/VerbalExpressions-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.kishikawakatsumi.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /VerbalExpressions/VerbalExpressions-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'VerbalExpressions' target in the 'VerbalExpressions' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_3_0 8 | #warning "This project uses features only available in iOS SDK 3.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /VerbalExpressions/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /VerbalExpressions/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // VerbalExpressions 4 | // 5 | // Created by kishikawa katsumi on 2013/08/12. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /VerbalExpressionsTests/VerbalExpressionsTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.kishikawakatsumi.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /VerbalExpressionsTests/VerbalExpressionsTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // VerbalExpressionsTests.h 3 | // VerbalExpressionsTests 4 | // 5 | // Created by kishikawa katsumi on 2013/08/12. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface VerbalExpressionsTests : SenTestCase 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /VerbalExpressionsTests/VerbalExpressionsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // VerbalExpressionsTests.m 3 | // VerbalExpressionsTests 4 | // 5 | // Created by kishikawa katsumi on 2013/08/12. 6 | // Copyright (c) 2013 kishikawa katsumi. All rights reserved. 7 | // 8 | 9 | #import "VerbalExpressionsTests.h" 10 | #import "VerbalExpressions.h" 11 | 12 | @implementation VerbalExpressionsTests 13 | 14 | - (void)setUp 15 | { 16 | [super setUp]; 17 | } 18 | 19 | - (void)tearDown 20 | { 21 | [super tearDown]; 22 | } 23 | 24 | - (void)testStartOfLine 25 | { 26 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"a"); 27 | 28 | STAssertTrue(verEx.test(@"a"), @"starts with a"); 29 | STAssertFalse(verEx.test(@"ba"), @"doesn't start with a"); 30 | } 31 | 32 | - (void)testEndOfLine 33 | { 34 | VerbalExpressions *verEx = VerEx().find(@"a").endOfLine(YES); 35 | 36 | STAssertTrue(verEx.test(@"a"), @"ends with a"); 37 | STAssertFalse(verEx.test(@"ab"), @"doesn't end with a"); 38 | } 39 | 40 | - (void)testFind 41 | { 42 | VerbalExpressions *verEx = VerEx().find(@"lions"); 43 | 44 | STAssertEqualObjects(@"(?:lions)", verEx.regularExpression.pattern, @"correctly build find regex"); 45 | STAssertTrue(verEx.test(@"lions"), @"correctly match find"); 46 | 47 | NSString *text = @"lions, tigers, and bears, oh my!"; 48 | STAssertTrue(verEx.test(text), @"match part of a string with find"); 49 | 50 | NSRegularExpression *regex = verEx.regularExpression; 51 | NSTextCheckingResult *match = [regex firstMatchInString:text options:kNilOptions range:NSMakeRange(0, text.length)]; 52 | NSString *result = [text substringWithRange:[match rangeAtIndex:0]]; 53 | STAssertEqualObjects(result, @"lions", @"only match the `find` part of a string"); 54 | } 55 | 56 | - (void)testMaybe 57 | { 58 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"a").maybe(@"b"); 59 | 60 | STAssertTrue(verEx.test(@"acb"), @"maybe has a b after an a"); 61 | STAssertTrue(verEx.test(@"abc"), @"maybe has a b after an a"); 62 | } 63 | 64 | - (void)testAnything 65 | { 66 | VerbalExpressions *verEx = VerEx().startOfLine(YES).anything(); 67 | 68 | STAssertTrue(verEx.test(@"what"), @"anything is matched"); 69 | STAssertTrue(verEx.test(@"The quick brown fox jumps over the lazy dog."), @"anything is matched"); 70 | } 71 | 72 | - (void)testAnythingBut 73 | { 74 | VerbalExpressions *verEx = VerEx().startOfLine(YES).anythingBut(@"w"); 75 | 76 | STAssertTrue(verEx.test(@"what"), @"starts with w"); 77 | } 78 | 79 | - (void)testSomething 80 | { 81 | VerbalExpressions *verEx = VerEx().something(); 82 | 83 | STAssertFalse(verEx.test(@""), @"empty string doesn't have something"); 84 | STAssertTrue(verEx.test(@"a"), @"a is something"); 85 | } 86 | 87 | - (void)testSomethingBut 88 | { 89 | VerbalExpressions *verEx = VerEx().somethingBut(@"a"); 90 | 91 | STAssertFalse(verEx.test(@""), @"empty string doesn't have something"); 92 | STAssertTrue(verEx.test(@"b"), @"doesn't start with a"); 93 | STAssertFalse(verEx.test(@"a"), @"starts with a"); 94 | } 95 | 96 | - (void)testReplace 97 | { 98 | NSString *testString = @"replace bird with a duck"; 99 | 100 | VerbalExpressions *verEx = VerEx().find(@"bird"); 101 | 102 | NSString *testStringAfterReplacement = verEx.replace(testString, @"duck"); 103 | NSString *expectedStringAfterReplacement = @"replace duck with a duck"; 104 | 105 | STAssertEqualObjects(testStringAfterReplacement, expectedStringAfterReplacement, @"replaced 'bird' with 'duck'"); 106 | } 107 | 108 | - (void)testLineBreak 109 | { 110 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"abc").lineBreak().then(@"def"); 111 | 112 | STAssertTrue(verEx.test(@"abc\r\ndef"), @"abc then line break then def"); 113 | STAssertFalse(verEx.test(@"abc\r\n def"), @"abc then line break then space then def"); 114 | } 115 | 116 | - (void)testBR 117 | { 118 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"abc").lineBreak().then(@"def"); 119 | 120 | STAssertTrue(verEx.test(@"abc\r\ndef"), @"abc then line break then def"); 121 | STAssertFalse(verEx.test(@"abc\r\n def"), @"abc then line break then space then def"); 122 | } 123 | 124 | - (void)testTab 125 | { 126 | VerbalExpressions *verEx = VerEx().startOfLine(YES).tab().then(@"abc"); 127 | 128 | STAssertTrue(verEx.test(@"\tabc"), @"tab then abc"); 129 | STAssertFalse(verEx.test(@"abc"), @"no tab then abc"); 130 | } 131 | 132 | - (void)testAnyOf 133 | { 134 | VerbalExpressions *verEx = nil; 135 | 136 | verEx = VerEx().startOfLine(YES).then(@"a").anyOf(@"xyz"); 137 | STAssertTrue(verEx.test(@"ay"), @"has an x, y, or z after a"); 138 | STAssertFalse(verEx.test(@"abc"), @"doesn't have an x, y, or z after a"); 139 | 140 | verEx = VerEx().anyOf(@"aeiou"); 141 | STAssertTrue(verEx.test(@"fox"), @"finds a vowel"); 142 | } 143 | 144 | - (void)testRange 145 | { 146 | VerbalExpressions *verEx = nil; 147 | 148 | verEx = VerEx().range(@[@"0", @"9"]); 149 | STAssertTrue(verEx.test(@"5"), @"works with a range of numbers"); 150 | STAssertFalse(verEx.test(@"Q"), @"works with a range of numbers"); 151 | 152 | verEx = VerEx().range(@[@"A", @"Z"]); 153 | STAssertTrue(verEx.test(@"Q"), @"works with a range of letters"); 154 | STAssertFalse(verEx.test(@"q"), @"works with a range of letters"); 155 | STAssertFalse(verEx.test(@"5"), @"works with a range of letters"); 156 | 157 | verEx.withAnyCase(YES); 158 | STAssertTrue(verEx.test(@"Q"), @"works with a range of letters"); 159 | STAssertTrue(verEx.test(@"q"), @"works with a range of letters"); 160 | } 161 | 162 | - (void)testWithAnyCase 163 | { 164 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"a"); 165 | 166 | STAssertFalse(verEx.test(@"A"), @"not case insensitive"); 167 | 168 | verEx.withAnyCase(YES); 169 | 170 | STAssertTrue(verEx.test(@"A"), @"case insensitive"); 171 | STAssertTrue(verEx.test(@"a"), @"case insensitive"); 172 | } 173 | 174 | - (void)testSearchOneLine 175 | { 176 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"a").br().then(@"b").endOfLine(YES); 177 | 178 | STAssertTrue(verEx.test(@"a\nb"), @"b is on the second line"); 179 | 180 | verEx.searchOneLine(YES); 181 | 182 | STAssertTrue(verEx.test(@"a\nb"), @"b is on the second line but we are only searching the first"); 183 | } 184 | 185 | - (void) testMultiple 186 | { 187 | VerbalExpressions *verEx = VerEx().startOfLine(YES).then(@"b").multiple(@"a").then(@"c").endOfLine(YES); 188 | STAssertTrue(verEx.test(@"baac"), @"multiple a, after b, before c"); 189 | } 190 | 191 | - (void)testOr 192 | { 193 | VerbalExpressions *verEx = nil; 194 | 195 | verEx = VerEx().startOfLine(YES).then(@"abc").or(@"def"); 196 | STAssertTrue(verEx.test(@"defzzz"), @"starts with abc or def"); 197 | STAssertFalse(verEx.test(@"xyzabc"), @"doesn't start with abc or def"); 198 | 199 | verEx = VerEx().find(@"http://").or(@"ftp://"); 200 | STAssertTrue(verEx.test(@"ftp://ftp.google.com/"), @"matches ftp://"); 201 | STAssertTrue(verEx.test(@"http://www.google.com"), @"matches http://"); 202 | } 203 | 204 | - (void)testCapture 205 | { 206 | NSString *text = @"Jerry scored 5 goals!"; 207 | VerbalExpressions *verEx = VerEx().startOfLine(YES).beginCapture().word().endCapture(); 208 | NSRegularExpression *regex = verEx.regularExpression; 209 | NSTextCheckingResult *match = [regex firstMatchInString:text options:kNilOptions range:NSMakeRange(0, text.length)]; 210 | NSString *result = [text substringWithRange:[match rangeAtIndex:1]]; 211 | STAssertEqualObjects(result, @"Jerry", @"successfully captures player by index"); 212 | } 213 | 214 | - (void)testURL 215 | { 216 | VerbalExpressions *verEx = VerEx() 217 | .startOfLine(YES) 218 | .find(@"http") 219 | .maybe(@"s") 220 | .find(@"://") 221 | .maybe(@"www") 222 | .anythingBut(@" ") 223 | .endOfLine(YES); 224 | 225 | STAssertEqualObjects(verEx.regularExpression.pattern, @"^(?:http)(?:s)?(?::\\/\\/)(?:www)?(?:[^ ]*)$", @"successfully builds regex for matching URLs"); 226 | STAssertTrue(verEx.test(@"http://google.com"), @"matches regular http URL"); 227 | STAssertTrue(verEx.test(@"https://google.com"), @"matches https URL"); 228 | STAssertTrue(verEx.test(@"https://www.google.com"), @"matches a URL with www"); 229 | STAssertFalse(verEx.test(@"http://goo gle.com"), @"fails to match when URL has a space"); 230 | STAssertFalse(verEx.test(@"htp://google.com"), @"fails to match with htp:// is malformed"); 231 | } 232 | 233 | @end 234 | -------------------------------------------------------------------------------- /VerbalExpressionsTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /coveralls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | trim() 4 | { 5 | trimmed=$1 6 | trimmed=${trimmed%% } 7 | trimmed=${trimmed## } 8 | 9 | echo $trimmed 10 | } 11 | 12 | # declare BUILT_PRODUCTS_DIR CURRENT_ARCH OBJECT_FILE_DIR_normal SRCROOT OBJROOT 13 | declare -r xctoolVars=$(xctool -showBuildSettings | egrep '(BUILT_PRODUCTS_DIR)|(CURRENT_ARCH)|(OBJECT_FILE_DIR_normal)|(SRCROOT)|(OBJROOT)' | egrep -v 'Pods') 14 | while read line; do 15 | declare key=$(echo "${line}" | cut -d "=" -f1) 16 | declare value=$(echo "${line}" | cut -d "=" -f2) 17 | printf -v "`trim ${key}`" "`trim ${value}`" # https://sites.google.com/a/tatsuo.jp/programming/Home/bash/hentai-bunpou-saisoku-masuta 18 | done < <( echo "${xctoolVars}" ) 19 | 20 | declare -r gcov_dir="${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}/" 21 | 22 | ## ====== 23 | 24 | generateGcov() 25 | { 26 | # doesn't set output dir to gcov... 27 | cd "${gcov_dir}" 28 | for file in ${gcov_dir}/*.gcda 29 | do 30 | gcov-4.2 "${file}" -o "${gcov_dir}" 31 | done 32 | cd - 33 | } 34 | 35 | copyGcovToProjectDir() 36 | { 37 | cp -r "${gcov_dir}" gcov 38 | } 39 | 40 | removeGcov(){ 41 | rm -r gcov 42 | } 43 | 44 | main() 45 | { 46 | 47 | # generate + copy 48 | generateGcov 49 | copyGcovToProjectDir 50 | # post 51 | coveralls ${@+"$@"} 52 | # clean up 53 | removeGcov 54 | } 55 | 56 | main ${@+"$@"} --------------------------------------------------------------------------------