Search code examples
javaregexrubular

Regex matches space between characters


I have this regex

(\((-?\d+.\d+\s?-?\d+.\d+,?)+\))*

that seems to be matching the space between characters at the very beginning of the string along with the parts that I would like to match.How can I change my regex to not match these as it causes empty arrays when converting to JSON?


Solution

  • Use + (one or more) instead of * (zero or more)

    (\((-?\d+.\d+\s?-?\d+.\d+,?)+\))+