I am tryting the match the following pattern:
((1.0 4) (2.0 5) .... (10.0 8))
The tuple (X N), where X is a floating point number with optional exponent and N is an integer, can be repeated several times.
I tried on this website and I could generate a regex for a fixed number of tuples. For example for 2 tuples I would get
^\(\(([+-]?(?=\.\d|\d)(?:\d+)?(?:\.?\d*))(?:[eE]([+-]?\d+))?\s[0-9]+\)\s\(([+-]?(?=\.\d|\d)(?:\d+)?(?:\.?\d*))(?:[eE]([+-]?\d+))?\s[0-9]+\)\)$
How can I modify the pattern so that the number of tuples is arbitrary? I think I will have to use some kind of grouping, but regex is quite new for me.
Xis the string representation of a non-negative float with one digit to the right of the decimal point andNwas the optional exponent. Now that I look at the regex you give I see neither of those assumptions were correct. At minimum you need to expand your example to include negative floats, exponents and so on. Also, make it a valid Javascript object (in part, no '....') so that readers can test code against your example and variants therefore, including invalid strings.