I have a huge list of the following in a large file that contains information about every country in the world.
They are arrays of temperature data, sometimes the spaces vary in length.
[23.5 26.3 29.3 31.9 32.8 31.2 28.8 27.8 28.4 29 26.6 23.7]
I'm attempting to use sublime to write a regular expression but I cannot get my head around them.
So far the closest thing I've got is:
( \S+)\(.+ )
How would one write a regular expression replacing the line to look like this:
[23.8,25.5,27.2,28.3,29.3,29.5,28.7,28.1,28.2,28.9,27.2,24.4]
Any help would be great thanks.
**Edit I'm using sublime text.
You can use this:
(?<=\d)\s+(?=\d|\-)
, using find and replace all in sublime text.(?<=\d)
is a positive lookbehind, it checks if the previous symbol is a digit, without actually matching it.(?=\d)
is a positive lookahead, same thing - checks if the following symbol is a digit, without actually matching it.Just FYI, lookbehinds aren't supported in javascript, but that doesn't matter in this case.
https://regex101.com/r/qX1qF5/7 for easier fiddling with it.