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}"
Asked
Active
Viewed 500 times
-14
Eddie Costa Domingues
- 37
- 1
- 1
- 6
-
@Eddia Please post your actual data – Mohammad Usman Jun 07 '16 at 10:06
-
what do you mean??? – Eddie Costa Domingues Jun 07 '16 at 10:07
-
See [ask] & **[mcve]**. – Tushar Jun 07 '16 at 10:07
-
@EddieCostaDomingues I mean the same as commented by Tushar – Mohammad Usman Jun 07 '16 at 10:09
-
@EddieCostaDomingues Do you want to get string between `{}`? – Mohammad Jun 07 '16 at 10:11
-
1Possible duplicate of [How do I split a string with multiple separators in javascript?](http://stackoverflow.com/questions/650022/how-do-i-split-a-string-with-multiple-separators-in-javascript) – BunkerMentality Jun 07 '16 at 11:52
2 Answers
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