## Regular Expressions

Regular expression over ∑={a,b,c} that represent all string of length

=>  (a+b+c)(a+b+c)(a+b+c)

String having zero or more

=> a*

String having one or more

=> a+

All binary string.

=>(0+1)*

0 or more occurrence of either a or b or both

=> (a+b)*

1 or more occurrence of either a or b or both

=> (a+b)+
Binary number end with 0

=>(0+1)*0

Binary number end with 1

=>(0+1)*1

Binary starts and end with 1.

=> 1(0+1)*1

String starts and ends with same

=> 0(0+1)*0  or   1(0+1)*1  or   a(a+b)*a  or  b(a+b)*b

All string of a and b starting with a

=> a(a/b)*

String of 0 and 1 end with 00

=> (0+1)*00

String end with abb

=> (a+b)*abb

=> 1(0+1)*0
All binary string with at least 3 characters and 3rd character should be 0

=>(0+1)(0+1)0(0+1)*

Language which consist of exactly two b’s over the set ∑={a,b}

=>a*ba*ba*

∑={a,b} such that 3rd character from right end of the string is always  a

=> (a+b)*a(a+b)(a+b)

Any number of a followed by any number of b followed by any number of c.

=> a*b*c*

binary string  should contain at least 3 one

=> (0+1)*1(0+1)*1(0+1)*1(0+1)*

String should contain exactly Two 1’s

=>  0*10*10*

Length should be at least be 1 and at most  3

=>  (0+1) + (0+1) (0+1) + (0+1) (0+1) (0+1)

binary string having number of zero should be multiple of 3

=> (1*01*01*01*)*+1*
∑={a,b,c} where a are multiple of 3.

=> ((b+c)*a (b+c)*a (b+c)*a (b+c)*)*

binary string having Even number of 0.

=> (1*01*01*)*

binary string having Odd no. of 1.

=> 0*(10*10*)*10*

String should have odd length

=> (0+1)((0+1)(0+1))*

String should have even length

=> ((0+1)(0+1))*

=> 0((0+1)(0+1))*

=>  1(0+1)((0+1)(0+1))*

Binary number having Even number of 1

=>   (0*10*10*)*

String of length 6 or less

=> (0+1+^)6

String ending with 1 and not contain 00

=>  (1+01)+

All string begins or ends with 00 or 11

=>  (00+11)(0+1)*+(0+1)*(00+11)

All string not contains the sub-string 00

=> (1+01)* (^+0)

Language of all string containing both 11 and 00 as substring

=> ((0+1)*00(0+1)*11(0+1)*)+ ((0+1)*11(0+1)*00(0+1)*)

Language of C identifier.

=> (_+L)(_+L+D)*