This is for an eggyal complimentary answer. This is a VBA regex feature so you can use its answer. You will notice that I added ignore_case as an option for flexibility, so your call will be as follows:
=RegexReplace(cell, "\s*-\s*test", "", TRUE)
Here is the function, I hope you find it useful:
' ------------------------------------------------------------------- ' Search and Replace using a regular expression ' ------------------------------------------------------------------- Function RegexReplace(ByVal text As String, _ ByVal replace_what As String, _ ByVal replace_with As String, _ Optional ByVal ignore_case As Boolean = False) As String Dim RE As Object Set RE = CreateObject("vbscript.regexp") RE.ignorecase = ignore_case RE.pattern = replace_what RE.Global = True RegexReplace = RE.Replace(text, replace_with) End Function
source share