parsing a string

Hai everyone,

In my application i need to capture the domain name of any email -id which is passed to my application i.e., when a mail-id like,say abc@xyz.com is passed to my application, i need to know the position of the @ symbol of that id and then i had to get the content(domain name) which follows this @ symbol. So i had to use the indeof() operation here to get the position of @ symbol and then capture the substring that follows it. But i am not getting it right.

I request you to give me an idea of how to get it and if possible plz provide me with some sample code.

Thank you,

[614 byte] By [autoa] at [2007-10-1 20:52:55]
# 1
Post your existing code and sample output, and someone might be able to help you.- Saish
Saisha at 2007-7-13 2:50:25 > top of Java-index,Administration Tools,Sun Connection...
# 2
hi,for u r case use regular expression to match the pattern
rustona at 2007-7-13 2:50:25 > top of Java-index,Administration Tools,Sun Connection...
# 3

hi

You can use the code which is shown below

I think this solves this problem

public class TestString

{

public static void main(String args[])

{

String str = "abcd@xyz.com";

int index = str.indexOf("@");

System.out.println(" "+str.substring(index+1,str.length()));

}

}

rakesh.sagara at 2007-7-13 2:50:25 > top of Java-index,Administration Tools,Sun Connection...
# 4
String email = // fill it as you like String rh = email.replaceAll("^.*@","");Replace the portion of the address from the beginning to the @ sign to the empty string.
BIJ001a at 2007-7-13 2:50:25 > top of Java-index,Administration Tools,Sun Connection...