There is no default RegEx library on the iPhone. Is it ok if I use UIWebView's stringByEvaluatingJavaScriptFromString
to evaluate a JavaScript string that actually uses the RegExp object to evaluate an expression? Is this supported on the iPhone?
views:
209answers:
3
+2
A:
Of course, you can always just try it and find out, but there's probably another way to get what you need. The NSPredicate
class, for example, allows string matching on regular expressions. If you need to do searching, I'm not sure about that, but take a look at this article for matching anyway.
Ed Marty
2009-11-05 14:02:45
+1
A:
Yes, it's possible, here's a sample code. The idea behind doing it this way might be to support Javascript-compliant Regular Expressions, leading to reuse and portability of existent JS Regexp code you might have:
UIWebView *wb = [[UIWebView alloc] init];
NSLog(@"%@", [wb stringByEvaluatingJavaScriptFromString:
@"re = new RegExp('su{1,3}p+er'); re.test('suuuper')"]);
luvieere
2009-11-14 20:36:11