开发者

Cocoa Touch NSRegularExpression patterns

I have an application that I'm writing, which gets some HTML from a website. I have a string with the HTML, and there are certain tags which I would like to get information f开发者_StackOverflow中文版rom. However, I need to use wildcards, since certain attributes of the tag change after every request. I would like to get information from all tags that I need at once, so I don't need to search through the HTML too much. Can somebody please explain/point me to a tutorial on NSRegularExpression patterns and using it? I have looked online, on Stackoverflow, and on the Apple Documentation, and I didn't find anything helpful. Also, if somebody knows another way for me to do the same thing, please post as well.


Could you use an NSXMLParser instead? I'm not sure if it would suit your specific application, but it would only require going through the HTML string once. You can simply have one "if" statement per tag, so wildcards aren't really needed either.

If you haven't used NSXMLParser before, the Event-Driven XML Programming Guide is very helpful.


I tried using the NSRegularExpression documentation online, and after I understood the basics of regex patterns in general it was easier to understand it. If you look online you can find many regex pattern explanations, and the NSRegularExpression documentation is available here for iOS: http://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html

and for OS X Lion: http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSRegularExpression_Class/Reference/Reference.html.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜