This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Extract an Email From a String literal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Extract an Email From a String literal" Watch "Extract an Email From a String literal" New topic
Author

Extract an Email From a String literal

Steven Ho
Greenhorn

Joined: Jan 16, 2003
Posts: 15
Hello all,
I have the code below,

The length of string may change often, more character may appear at the start or end sometime as the variable is modified, but the "this is email:" part exist all the time.
There is always 1 valid email only inside the string.
How do I extract the email from the string? Please provide code samples.
Thanks all.
[ September 09, 2003: Message edited by: Steven Ho ]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
What have you tried so far? Or what have you considered trying? Are you familiar with regular expressions? They might prove useful to you.
Feel free to post code that you've been working on.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Steven Ho
Greenhorn

Joined: Jan 16, 2003
Posts: 15
Hello,

sorry, I forgot to mention the last character is always line break.
Thanks all for replying.
Tom Hill
Ranch Hand

Joined: Aug 24, 2003
Posts: 115
String Tokenizer could be useful for that.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Here's an excerpt from an app I developed this summer that you might find useful.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Try this
 
Consider Paul's rocket mass heater.
 
subject: Extract an Email From a String literal
 
Similar Threads
Add days to date() calculations
JSP makes me headache
ResultSet problem
Extracting text from html using htmlparser
In the same jsp page I want to display data fetched from database