Another one-line approach to getting rid of ".asm" at the end, and not to "asm" in the middle of the line:
stringValue = System.Text.RegularExpressions.Regex.Replace(stringValue,".asm$","");
"$" matches the end of the line.
To match ".asm" or ".ASM" or any equivalent, you can optionally specify Regex.Replace to ignore case:
using System.Text.RegularExpresions; ... stringValue = Regex.Replace(stringValue,".asm$","",RegexOptions.IgnoreCase);
source share