Jump to content

Regex in iPhone?


3 posts in this topic

Recommended Posts

Any really smart people know how I might be able to perform forms of regex on strings specifically with the limitations imposed on the iPhone? If at all possible I would hate to force the user to jailbreak their phone to install a command line to or some such...

 

I'm working with an Application that need to present data from both XML and HTML sources -- the xml is easy-peasy but some of the html I have to parse would be easier to work with if I could do some really powerful pattern matching and replacing via regex.. (or something similar)

 

Thanks!

 

Dave

Link to comment
Share on other sites

Any really smart people know how I might be able to perform forms of regex on strings specifically with the limitations imposed on the iPhone? If at all possible I would hate to force the user to jailbreak their phone to install a command line to or some such...

 

I'm working with an Application that need to present data from both XML and HTML sources -- the xml is easy-peasy but some of the html I have to parse would be easier to work with if I could do some really powerful pattern matching and replacing via regex.. (or something similar)

Doesn't libxml (which is included with the iPhone SDK) have an HTML parser?

 

Craig

Link to comment
Share on other sites

Doesn't libxml (which is included with the iPhone SDK) have an HTML parser?

 

It does but I wanna do things like the following to an entire html file that contains say 10s or 100s of urls and this is just an example I have other similar probles that regex would solve...

 

/<a href="([^"]*)">([<"]*)</a>/\2 url is \1/g (globally)

 

BTW that would take the following type of url whenever it was found in a string.

 

<a href="blah.com">blah-and-blah</A>

 

and turn it into:

 

blah-and-blah url is blah.com

 

Replacing blah-and-blah and blah.com with the unique and individual text found in each occurrence. Apple and apple.com one time News and new.com another etc etc etc.

 

Dave

Link to comment
Share on other sites

 Share

×
×
  • Create New...