I have a string like
var test = (-90.298205)
i want to remove ( )
character from this string using java script
Any thoughts? Thank you in advance for any help.
I have a string like
var test = (-90.298205)
i want to remove ( )
character from this string using java script
Any thoughts? Thank you in advance for any help.
You can use the string replace
function with regular expression
var test = "(-90.298205)";
test = test.replace(/[()]/g, "");
If the parentheses are always the first and last character, then you don't need a regular expression:
test = test.substring(1, test.length - 1);
Although it looks like you don't have a string. The expression (-90.298205)
is simply a (parenthesized) number. Why it's parenthesized is a mystery -- but you can't really "remove" the parentheses around it unless you remove those in the source itself. Even that won't change anything semantically (once parsed/interpreted, there's no difference between the parenthesized and non-parenthesized literal.)
You can Use .
var t = '(-90.298205)'; var output = t.replace(/[^\w\s\-\.]/gi, ''); alert(output);`
use substring for example:
var str = "Hello world!";
var res = str.substring(0, 10);
The result of res will be:
Hello world