I have created a java regex
(?=\b((?<![^\p{Alnum}\p{Punct}])(?:\p{Alnum}+\p{Punct}\p{Alnum}+){2})\b)
I tested this regex against a sample string: https://www.google.com.google.com
It is giving me all the expected tokens:
www.google.com google.com.google com.google.com
But, the issue with the above regex is that it is taking a lot of time when tested with a large string.
My expected tokens are in the form of "alphanumeric punctuation alphanumeric".
How can I optimize this regex?