-2

I have a string as follows:

var string = "=09e8d76c-c54c-32e1-a98e-7e654d32ec1f";

How do I remove the '=' character from this? I've tried a couple of different ways but the '=' character seems to be causing a conflict

Srini V
  • 11,045
  • 14
  • 66
  • 89
Anon
  • 845
  • 5
  • 30
  • 50

5 Answers5

1

If it's always the first character then this will work...

var string = "=09e8d76c-c54c-32e1-a98e-7e654d32ec1f".substring(1);

If it's not definitely the first character then this will work...

var string = "=09e8d76c-c54c-32e1-a98e-7e654d32ec1f".replace("=", "");

If it's in there more than once then this will work...

var string = "=09e8d76c-c54c-32e1-a98e-7e654d32ec1f".split("=").join("");
Reinstate Monica Cellio
  • 25,975
  • 6
  • 51
  • 67
0

You can use .replace():

The replace() method returns a new string with some or all matches of a pattern replaced by a replacement

string = string.replace('=','');

Fiddle Demo

Felix
  • 37,892
  • 8
  • 43
  • 55
0

Its very simple.

var string = "=09e8d76c-c54c-32e1-a98e-7e654d32ec1f";
string=string.replace('=','');
Tuhin
  • 3,335
  • 2
  • 16
  • 27
0

To get rid of the first character:

string = string.substring(1);
cybersam
  • 63,203
  • 6
  • 53
  • 76
0

Do this:

var string = "=09e8d76c-c54c-32e1-a98e-7e654d32ec1f";
if(string.indexOf('=')>=0){ //check string contains =
   string = string.replace("=",'');
}
Somnath Kharat
  • 3,570
  • 2
  • 27
  • 51