Reputation: 1193
I am trying to write a C code that will find hyperlinks in a mail and replace them. Is using a pcre library a good thing to do ? Since pcre is ,allegedly, too slow is there an alternative ?
Upvotes: 3
Views: 792
Reputation: 60768
C is the last language I would choose to do this. Firstly, if you want to do this with high accuracy - use a MIME parser to get the HTML body out. Java has mime4j, Perl has MIME::Parser, Python has email, etc. This isn't too hard and I'm willing to help with this step in any of these languages if you'd like. Secondly, use an HTML parser to isolate the links.
If you're ok with some mistakes then just write a one-line program in Perl or PHP. Or sed even. Really. If you are replacing with a fixed URL, use sed. If you are modifying the URL, the only reason this won't work as-is is you'll probably have to url_encode it which a P-language can handle in one line.
Upvotes: 3