+ Start a Discussion
woodmanzeewoodmanzee 

string remove method not exist error... straight from documentation

So I am trying to call a simple string method to remove a specified set of characters from an existing string, and I keep getting an error message that says: 

 

Error: Compile Error: Method does not exist or incorrect signature: [String].remove(String) at line 10 column 30

 

So my code is fairly simple so far, all I have is this

trigger updateTextEmail on Contact (before insert, before update) {

    List<String> contactNames = new List<String>{};

    for(Contact c: Trigger.new){

        if (c.MobilePhone != '') {
            
           String phone = c.MobilePhone;
           String numPhone = phone.remove('()- ');
            
        }

    }

}

 

So why doesn't the remove method work? I have copied and pasted the method example straight from the documentation, and even that throws an error. Is there something I have to import/include? 

 

Thanks in advance

BritishBoyinDCBritishBoyinDC

The Remove method is new to the Winter 13 release - so check the org you are developing on has been upgraded, and/or the classes you are using are using API v 26

aj2taylo2aj2taylo2

Is this method new for Winter '13?  I haven't used it before, wondering if its new and not released to your org yet.

 

You could use the replace method instead for now.

aj2taylo2aj2taylo2

BritishBoy, I just missed your reply!