Question: I have the following strings:
One Rule : Get all consecutive Square bracket strings : for example,

> 
> string 1 : [hello][qwqwe:]sdsdfsdf [note2]   
>  string 2 :
>  [somethingelse]sdfsdf [note 1]   
>  string 3 : aasdad[note 3]
> 
> 
> 

I would like to get the substrings : 

> 
> output 1 : [hello][qwqwe:]   
>  output 2 : [somethingelse]   
>  output
>  3 :
> 
> 
> 

If the string doesn't have square brackets, I do not want an output.
If the string has a square bracket delimited string which is not consecutive, it should not match aswell.

I tried using the regex expression 

> 
> ([.\*])\*
> 
> 
> 

But it matches everything between two square brackets. If you notice the first string, I do not need the part of the string that violates my rule.

Answer: 
you can use this regular expression.

```
^(\[(.*?)\])*

```

C# code for matching:

```
        var regex = new Regex(@"^(\[(.*?)\])*");

        var inputTexts = new string [] {"[abcd]xyz[pqrst]","abcd[xyz][pqr]","[asdf][abcd][qwer]sds[qwert]" };

        foreach (var match in inputTexts.Select(inputText => regex.Match(inputText)))
        {
            Console.WriteLine(match.Value);
        }           

        //result1 - [abcd]
        //result2 -
        //result3 - [asdf][abcd][qwer]

```
You can adjust four things from you original regex to make it work: 1) use non-greedy match `.*?`, 2) add `^` to match from beginning of string, 3) escape the square brackets, and 4) change final `*` to `+` to require at least one group of square brackets:

```
^(\[.*?\])+

```