I am working on some string generator task. I have some sample string duplicate_config_dev_V2 and I want to get output duplicate_config_dev. If input is duplicate_config_dev_V3 then I want to get duplicate_config_dev. I tried as below.
int countUnderScore = input.Count(c => c == '_');
if(countUnderScore > 0 )
{
input = input.Split('_')[countUnderScore-1];
}
This code returns Dev as output but I want to return duplicate_config_dev.