Skip to main content
deleted 2 characters in body
Source Link
sfdcfox
  • 501.7k
  • 21
  • 473
  • 828

I have following code :

     `forfor(String s:valuearray){
        String s9 = s;
        system.debug('startvalue!!'+s9+'******'+s9.remove(' '));
        List<String> li = s.split(';');
        system.debug('li----'+li);
       
        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }`

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.

I have following code :

     `for(String s:valuearray){
        String s9 = s;
        system.debug('startvalue!!'+s9+'******'+s9.remove(' '));
        List<String> li = s.split(';');
        system.debug('li----'+li);
       
        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }`

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.

I have following code :

     for(String s:valuearray){
        String s9 = s;
        system.debug('startvalue!!'+s9+'******'+s9.remove(' '));
        List<String> li = s.split(';');
        system.debug('li----'+li);
       
        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.

added 3 characters in body
Source Link

I have following code `for(String s  :valuearray){ String s9 = s; system.debug('startvalue!!'+s9+'******'+s9.remove(' ')); List li = s.split(';'); system.debug('li----'+li);

     `for(String s:valuearray){
        String s9 = s;
        system.debug('startvalue!!'+s9+'******'+s9.remove(' '));
        List<String> li = s.split(';');
        system.debug('li----'+li);
       
        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }`

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.

I have following code `for(String s:valuearray){ String s9 = s; system.debug('startvalue!!'+s9+'******'+s9.remove(' ')); List li = s.split(';'); system.debug('li----'+li);

        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }`

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.

I have following code  :

     `for(String s:valuearray){
        String s9 = s;
        system.debug('startvalue!!'+s9+'******'+s9.remove(' '));
        List<String> li = s.split(';');
        system.debug('li----'+li);
       
        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }`

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.

Source Link

String function cannot read white spaces

I have following code `for(String s:valuearray){ String s9 = s; system.debug('startvalue!!'+s9+'******'+s9.remove(' ')); List li = s.split(';'); system.debug('li----'+li);

        System.debug('test%%%%%%%%%'+li[0]+'**'+li[0].deleteWhitespace());
       
       
        system.debug('no of whitespace--'+li[0].countMatches(' '));
       
        
       
        Decimal d = Decimal.valueof(li[0].deleteWhitespace());
        if(li[1] != '')
            m.put(li[1],d); 
        singtotal = singtotal +d;          
    }`

ValueArray is coming as an array of string from Javascript function in a Lightning component. This code removes whitespaces the first time loop runs(e.g first string in valueArray is '12 000;Q1'). The next time loop runs(eg second string in valueArray is '80 000 000 000;Q2'), it does not read the whitespace, neither does it remove it. Apart from deletewhitespace(),I tried to use replace(), replaceAll(). I tried to use containswhitespace() to check if it is reading the whitespaces or not, but everything works for the first run. What can be the issue.