VERTEX("^" + ".*?" + "v" +
"(\\s-{0}?-{0,1}?\\d{1,}?){3,4}?" +
// "\\s(-{0,1}?\\d+?)" +
// "\\s(-{0,1}?\\d+?)" +
// "\\s{0,}?"+"(-{0,1}?\\d+?){0,1}?" +
".*?" + "$"),
Is supposed to find:
v x y z w
Where ‘w’ is optional.
Initially I got it working however I was trying to simplify it greatly by doing this:
“(\s-{0}?-{0,1}?\d{1,}?){3,4}?”
Here is the problem.
I break up the original string into:
(\s-{0}?-{0,1}?\d{1,}?) + {3,4}?
1st half is supposed to look for something like this:
" -133"
The second part of the string is supposed to find that pattern a minimum of 3 times and a max of 4.
However the output is all wrong.
Why?
Sample output:
1.0, 0.0, 0.0, 0.0,
-1.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0,
-1.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0,
-1.0, 0.0, 0.0, 0.0,
1.0, 0.0, 0.0, 0.0,
-1.0, 0.0, 0.0, 0.0,
How it should look:
1 1 1
1 1 -1
1 -1 1
1 -1 -1
-1 1 1
-1 1 -1
-1 -1 1
-1 -1 -1
Everytime I need regex it tears my heart out.
It’s the one thing that really cracks me.


