cancel
Showing results for 
Search instead for 
Did you mean: 

How to Read a String up to a praticular character

Former Member
0 Kudos

Hi All,

This is the String Value "ashokkumar@yahoo.co.in" from the string value I have to Read Upto "@" character.

Could you hlep me how to Read value upto "@" because I have to sent userName to my target structure.

Thanks and Regards,

Ashok.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ashok

You can write a simple UDF code

int y=a.indexOf('@');

return a.substring(0,y);

Thanks

Sai

Answers (2)

Answers (2)

Former Member
0 Kudos

Malavathu,

Create a <b>Value</b> user defined function and name it as <b>GetValue</b>. Take one argument as <b>a</b>. Import <b>Java.*;</b>

Add this code inside it:

int i = a.indexOf("@");

a = a.substring(0,i);

return(a);

Regards,

---Satish

justin_santhanam
Active Contributor
0 Kudos

Ashok,

You can use StringTokenizer.

StringTokenizer st = new StringTokenizer("ashokkumar@yahoo.co.in","@");

return ""st.nextToken()"";

The above value returns you ashokkumar.

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

I am Ashok can I write the code like this

for (int i=0; i<a.length;i++)

{

StringTokenizer st = new StringTokenizer(a,"@");

return ""st.nextTokens()"";

}

Regards,

ashok.