Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OORegExpMatcher.h
Go to the documentation of this file.
1/*
2
3OORegExpMatcher.h
4
5Regular expression utility built on top of JavaScript regexp objects in lieu
6of Objective-C regexp support. Not thread-safe.
7
8If we had a performance-critical need for regexps, I'd want a real library,
9but this will do for light usage.
10
11
12Copyright (C) 2010-2013 Jens Ayton
13
14Permission is hereby granted, free of charge, to any person obtaining a copy
15of this software and associated documentation files (the "Software"), to deal
16in the Software without restriction, including without limitation the rights
17to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18copies of the Software, and to permit persons to whom the Software is
19furnished to do so, subject to the following conditions:
20
21The above copyright notice and this permission notice shall be included in all
22copies or substantial portions of the Software.
23
24THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30SOFTWARE.
31
32*/
33
34#import "OOCocoa.h"
35#include <jsapi.h>
36
38
39
40enum
41{
43 kOORegExpMultiLine = JSREG_MULTILINE
44};
45
46
47@interface OORegExpMatcher: NSObject
48{
49@private
53 NSUInteger _cachedFlags;
54}
55
56+ (instancetype) regExpMatcher;
57
58- (BOOL) string:(NSString *)string matchesExpression:(NSString *)regExp;
59- (BOOL) string:(NSString *)string matchesExpression:(NSString *)regExp flags:(NSUInteger)flags;
60
61@end
62
63
64@interface NSString (OORegExpMatcher)
65
66- (BOOL) oo_matchesRegularExpression:(NSString *)regExp;
67
68@end
@ kOORegExpMultiLine
@ kOORegExpCaseInsensitive
OOJSValue * _cachedRegExpObject
NSString * _cachedRegExpString
NSUInteger _cachedFlags
OOJSFunction * _tester