Possible strings are:
public class MyClass extends ParentClass {
or
public class MyClass throws SomeException {
or just
public class MyClass {
I am using the following pattern to always capture MyClass:
ptrn = "((public|private|protected)\s+(.*)\s*[class|interface]\s+(\w+))"
But when I do
regex = re.search(ptrn, text)
className = regex.group(4)
for 1 and 2 I get ParentClass and SomeException respectively and only for 3 I get MyClass.
What is wrong with my regex pattern and how do I fix it?