This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes replacing email address with email link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "replacing email address with email link" Watch "replacing email address with email link" New topic
Author

replacing email address with email link

limpan luring
Greenhorn

Joined: Oct 23, 2004
Posts: 4
I want to do some filtering of raw text from text files or database entries to publish on a web site.
The problems include filtering out existing html tags, replacing email addresses with html email links, and creating html links from web addresses (starting with http )
The idea is to do it in a general enough way to make it easy to add and replace filters later on.

To start with I'd like input for howto make the replacements.
Has anyone done this in a good/not so good way?

[ October 24, 2004: Message edited by: limpan luring ]
[ October 24, 2004: Message edited by: limpan luring ]

Gentoo 2.6.9-r1<br />Tomcat 5.0.28
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
http://htmlparser.sf.net


Tony Morris
Java Q&A (FAQ, Trivia)
limpan luring
Greenhorn

Joined: Oct 23, 2004
Posts: 4
Thanx. Had a quick look at htmlparser, but it seems to be a bit overkill for my purposes.

Here's what I did (quick and dirty):

... and so on.
Applying these methods one after another (as is the idea behind the stuff) seems to be a bit inefficient, with all the String stuff going on. Any ideas on how to improve this? Not too sure about the regexps either ...
[ October 24, 2004: Message edited by: limpan luring ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
why reinvent the wheel?
You may think using an existing toolkit is overkill now but before you know you've rewritten over half the functionality...

As to email addresses: that's highly unreliable (unless your data is tabulated to tell you exactly where they are).
There's too many possible things that can go wrong.
is x@y.z an email address or not?
And what about a.b@c.e.f.g ?


42
 
wood burning stoves
 
subject: replacing email address with email link
 
Similar Threads
GMAIL
Threads-Tutorial ??
next upgrade in a few days
I met Simon Roberts today
How do I get docroot from the servlet