user469652
user469652

Reputation: 51241

Change string using JavaScript

var a = "Text(money ='3/3/dollor',unit=42)";

I want to get rid of money ='3/3/dollor',

Using javascript, how to do this?

Sorry I did not make this very clear, the string after money = can be anything but they are string for sure, and always ends up with an comma.

More samples

var a = "Text(money ='v23f3/.3/dollor',unit=42)";
var a = "Text(money ='3/3fds/d.ollor',unit=42)";
var a = "Text(money ='3.3.3.3/3/d.o/l.lor',unit=42)";
var a = "Text(money ='3/3/dollor',unit=42)";

The output I need is a = "Text(unit=42)"

Upvotes: 2

Views: 124

Answers (1)

Marcel Korpel
Marcel Korpel

Reputation: 21763

a = a.replace(/money ='.*',/, "");

Upvotes: 2

Related Questions