why does the following regex matches
===

I have the regex:  `(?ms)(?<attribute>\[.+?\]|public|private|\s)+?class`

and I have the text:

    [attribute]
    public int a;
    
    [attribute C]
    [attribute B]
    public class Test{
    
    }

**I will like to know why does the regex that I posted matches:**

    [attribute]
    public int a;
    
    [attribute C]
    [attribute B]
    public class

**I think it should match:**
    
    [attribute C]
    [attribute B]
    public class


----------


Correct me if I am wrong. I think the way that regex is supposed to be read is:

> find eather an attribute ( [ some attribute ] ) or public key word or private keyword or space. so first the regex engine should match [attribute] then the \n (new line) then the public keword then the keyword int is not an option so why does it matches it?
