How to trim space & - from the short description

ArunG29061990
Tera Expert

Hi,

 

I was modifying one catalog where I need to manipulate the short description.

 

My short description was "Configuration Incident Response Team - P2P - AnyERP Task - High Memory/CPU - Tenant: KOK - SIDK - ServiceProvider" but my requirement is "Configuration Incident Response Team - P2P - AnyERP Task - High Memory/CPU - Tenant: ServiceProvider"

 

So I already removed this KOK - SIDK with the help of community by adding the below-given code:

 

current.short_description += producer.Issue_Category + " - " + "Tenant: " + producer.getDisplayValue("cmdb_ci");

var prefixToRemove = "KOK - SIDK";
if (current.short_description.includes(prefixToRemove))
{ current.short_description = current.short_description.replace(prefixToRemove,'').trim(); }

 

but this code is not removing space & - from the short description so tried this:
var prefixToRemove = "KOK - SIDK - ";

 

after adding "space -" in var, it's breaking the whole code and it's not even removing "KOK - SIDK". 

 

So can you please suggest how to remove "Space -" along with "KOK - SIDK" from the short description of catalog with the same code?