I'm working with an angular project. I have a string like below and i sorted out all the special characters using regular expressions. Now, I want the first 2 strings to be in suare brackets and the second two in another square bracket like coordinates, and the output should be like below. Please help me achieve the functionality.
test: any = "((-1.23568 75.87956), (-1.75682 22.87694))"
My ts code be like:
hello()
{
this.new = ( this.test.replace(/[^\d. -]/g, ''));
this.newarr = this.new.split(" ");
const result = this.newarr.filter(e => e);
}
and my final output in result array is like:
["-1.23568", "75.87956", "-1.75682", "22.87694"]
Desired output
[ ["-1.23568", "75.87956"], ["-1.75682", "22.87694"] ]