You need to sign in to do that
Don't have an account?
Nageswara reddy
String Split method is not working in apex class
HI all,
String method is not working in my apex class ,
I have written in my apex class like this
String address=add2;
string[] spilt= address.split(';');
for(string s: spilt)
{
system.debug('***********'+s);
}
Its Not spiltting,
Bur same code when run in console it will work
String address='Abbyville,null,Kansas,92274|1520 Malley Road,Anchorage,Alaska,99501|';
string[] spilt= address.split(';');
for(string s: spilt)
{
system.debug('***********'+s);
}
can any one help y it is not spiltting
Thanks
Nageswar
Hi,
Put a debug after "String address=add2;" to see what value it has. Maybe the string is empty.
Regards,
Adrian
Hi
you are aplitting it based on ';'.
On your strin you just have one ';' so you will be getting the entire string.
Do the splitting based on ','.
thanks prakash,
actullay the string contain two adresses that are separated by semi colon. i want split the address es with semi coln
Hi i also put debug , but string is not empty it contains "Abbyville,null,Kansas,92274|1520 Malley Road,Anchorage,Alaska,99501|' " thisw value. In the string we have two adresses , they are separated them by semi colon
Really weird... if it works in the console why wouldn't it work inside your class??
Try escaping the ;.
String[] spilt = address.split('\\;');
HI adrin,
I tried in that Manner also, it is not splitting .By defaultly it takes orginal string.
In addition, can you post the code or process as to how the add2 is constructed....