user3024007
user3024007

Reputation: 283

.replace() variable string name

Will this effectively delete strings like: t_someString, o_someString, a_someString etc? I don't know what the first character is going to be, _someString is the only known factor

.replace( \*\ + '_someString', '' )

Upvotes: 0

Views: 55

Answers (1)

tckmn
tckmn

Reputation: 59273

Huh? What's with the backslashes? And the asterisk? And the plus sign? Not sure what you're doing....

Anyway, here's a regex for that:

yourString = yourString.replace(/._someString/g, '')

. means "any character". The g flag is for global matching, so it replaces all occurences.

Upvotes: 2

Related Questions