I’m trying to use a Scanner to read in lines of code from a string of the form “p.addPoint(x,y);”
The regex format I’m after is:
*anything*.addPoint(*spaces or nothing* OR ,*spaces or nothing*
What I’ve tried so far isn’t working: [[.]+\\.addPoint(&&[\\s]*[,[\\s]*]]
Any ideas what I’m doing wrong?
I tested this in Python, but the regexp should be transferable to Java:
Your regexp seems seriously malformed. Even if it wasn’t, matching infinitely many repetitions of the
.wildcard character at the beginning of the string would probably result in huge swaths of text matching that aren’t actually relevant/desired.Edit: Misunderstood the original spec., current regexp should be correct.