-14

So for example I want to use the split() method on these characters "{" & "}" and the string that I'm going to split looks like this "{99}"

2 Answers2

1

Do you want to remove those characters or split on those characters to form an array? Your question is confusing and you should consider re-phrasing it.

If you want to remove them:

console.log("{99}".replace(/[{}]/g, "")) /* "99" */

If you want to split on them:

console.log("{99}".split(/[{}]/g)) /* ["", "99", ""] */
Sebastian Simon
  • 16,564
  • 7
  • 51
  • 69
wot
  • 827
  • 4
  • 10
0

You can use String.prototype.slice() method here:

var str = "{99}";

console.log(str.slice(1, -1));
Mohammad Usman
  • 34,173
  • 19
  • 88
  • 85