PDA

View Full Version : Best way to parse a simple html text?




Clouds
May 26, 2011, 03:10 AM
Hi,
I have a simple html/xml text like this:
<script type="text/javascript">
window.location.href="http://www.google.com?search=xxxxxx&d=yyyyy";
</script>
please tell me the best way to parse the link http://www.google.com?search=xxxxxx&d=yyyyy in that html text.
Thank you!



Hansr
May 26, 2011, 04:05 AM
Okay so parse and capture all URI?

Might try some of the regex from here:
http://www.regxlib.com/DisplayPatterns.aspx?cattabindex=1&categoryId=2

This one looks simple enough to start off with but can be extended to be more restrictive or allow for more variability:

[a-zA-Z]{3,}://[a-zA-Z0-9\.]+/*[a-zA-Z0-9/\\%_.]*\?*[a-zA-Z0-9/\\%_.=&amp;]*

seepel
Jun 4, 2011, 06:30 PM
If you're sure that it will stay that simple NSXMLParser could work. If this is in a UIWebView you might be able to work some javascript magic...