Question: Hello guys I need to find a regular expression that takes strings with two sets of 11 only
from a set {0,1,2}

```
0011110000          match it only has two sets
0010001001100       does not match (only has one set)
0000011000110011    does not match (it has three sets)
00                  does not match (it has no set
0001100000110001    match it only has two sets

```

This is what I've done so far

```
([^1]|1(0|2|3)(0|2|3)*)*11([^1]|1(0|2|3)(0|2|3)*)*11([^1]|1(0|2|3)(0|2|3)*|1$)*
                                                     --------------------------

```

I think what I'm missing is that I need to make sure the underlined section of the above regular expression has to make sure there is no more "11" left in the string, and I don't think that section is working correctly.

Answer: 
You *could* use a regular expression, but you've got much simpler options available to you. Here's an example in C#:

```
public bool IsValidString(string input)
{
   return input.Split(new string[] { "11" }, StringSplitOptions.None).Length == 3;
}

```

Although regular expressions can be a very useful tool, their usage is not always warranted. As [jwz put it](http://regex.info/blog/2006-09-15/247):

> 
> Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
> 
> 
>
There may be a simpler way, but starting with your approach, this seems to work on the sample data provided:

```
/^([^1]|1[023])*11([^1]|1[023])*11((?<!11)|1[023]|[023]|(?<=[023])1)*$/

```

Using lookbehind.