+ Start a Discussion
SFDC Learning 6SFDC Learning 6 

Trim character from Map Key

I am trying to trim characters after ';' character  from map keys. 
For Example: 

{10;00o5B000000AcrdQAC=4583.00000000, 10;00o5B000000AcrqQAC=7250.00000000, 11;00o5B000000AcreQAC=4583.00000000}

want to compare key value with list of integerts {1,2,3,4}
Please suggest the way if you have any.

Thanks in advance.

 
v varaprasadv varaprasad
Hi ,

Please check once below sample code: 
map<string,string> mapStr = new map<string,string>{'10;00o5B000000AcrdQAC'=>'4583.00000000',
    '10;00o5B000000AcrqQAC'=>'7250.00000000',
    '11;00o5B000000AcreQAC'=>'4583.00000000'};
system.debug('==mapStr=='+mapStr.keyset());

map<string,string> allStrs = new map<string,string>();
for(string st : mapStr.keyset()){
    string str = st.substringAfter(';');
   allStrs.put(str,mapStr.Get(st));
}
system.debug('==allStrs==:'+allStrs);

I hope it helps you.
Please let me know in case of any other assistance.

Thanks
Varaprasad