Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extract an Email From a String literal

 
Steven Ho
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steven Ho
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

sorry, I forgot to mention the last character is always line break.
Thanks all for replying.
 
Tom Hill
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String Tokenizer could be useful for that.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an excerpt from an app I developed this summer that you might find useful.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic