Which is the fastest way to get a URL from an HTML tag (Regex, NScanner, Hppple)?
I found 3 different way to get the value of the src
attribute of an img
tag in an HTML string.
- With a Regex using RegexKitLite.
- With TFHpple HTML parser
- Using a NSSCanner to scan the HTML string.
So which way I must use to optimize performance of my iPhone app?
Maybe not the fastest, but RegEx is imho the most versatile and portable method. And unless you're really doing hundreds of parses per second, you won't notice the performance hit you'll get by not using the fastest method around..
I use lots of regexes on iPhone for user input validation while the user is entering text (so a lag would certainly be seen). Never had any problems.
精彩评论