+ Start a Discussion

String Contains Sub String from right

In the Physical County i will be getting string such as 'Wayne County' or 'Oakland County' so my requirement is to remove the county and just update as 'Wayne'  or 'Oakland' Below code is working fine, but i need to check if physical_county__c contains 'County' string onky from the right side that is if we have last 6 sub string as County then enter the IF condition.. Can any one help me out on this. 

Below is my code, 
fa.Physical_County__c = fa.Physical_County__c.substring(0,fa.Physical_County__c.length()-6);