1

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?

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

There is the BSD "C" regex library on the iPhone, I have used it in a couple of apps. man:regex

Comments

1

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')"]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.