## Introduction

This blog will discuss some of the **Examples of Regular Expressions**. A regular expression (also known as a rational expression) is a character sequence that determines a text search pattern. String-searching algorithms typically use such patterns for string operations like "find" or "find and replace", as well as for input validation.

Regular expressions are a generalized method of **matching patterns with character sequences**. Every programming language, including C, Java, and Python, uses it.

Also See, __Moore Machine____, ____Arden's theorem__

## Examples of Regular Expressions

Let's now look at some examples of regular expressions.

**â†’** Make a regular expression for a language that accepts all strings, which starts with 1 and ends with 0.

So this language will accept any string with 1 in the starting, 0 in the end, and a binary string in between. Therefore the regular expression will be:

`R = 1 (0 + 1)* 0`

**â†’** Make a regular expression for a language that accepts all strings which start with 'a' but do not contain consecutive b's.

Here mentioned language L = [a, ab, aba, aab, â€¦.. ]

Therefore the regular expression will be:

`R = (ab + a)*`

**â†’** Make a regular expression for a language that accepts all strings which contain any number of a, b and c, and in the same order.

We know that any number of x's is expressed in regular expression as x*. Also given in the question that order is a, then b, and c at last. Therefore the regular expression will be:

`R = a* b* c* `

**â†’** Make a regular expression for a language that accepts all binary strings of even length which contains only zero.

As it is mentioned that the required strings must be of even length and should only contain zero.

So the language **L = [ âˆŠ, 00, 0000, â€¦. ]**. Therefore the regex will be:

`R = (00)*`

**â†’** Make a regular expression for a language that accepts all binary strings which do not contain any substring of form 01.

As there should not be any 1 followed by a zero.

So the language **L = [ âˆŠ, 0, 1, 10, 100, 110, 1000, 1100, â€¦].** Therefore the regex will be:

`R = 1* 0*`

**â†’** Make a regular expression for a language that accepts all binary strings in which every zero (if any) is followed by 11.

So the language **L = [ âˆŠ, 1, 11, 011, â€¦].** Therefore the regex will be:

`R = (1 + 011)* `

**â†’** Make a regular expression for a language that accepts all binary strings which have at least one '1' and one '0'.

So there should be at least one 1 and 0 in the string. Now there can be two cases.

i) whether 1 comes before 0

ii) whether 1 comes after 0

The regex that will include both the cases is:

`R = (0+1)* 1 (0+1)* 0 (0+1)* + (0+1)* 0 (0+1)* 1 (0+1)*`

Also check out - __Substr C++__

Also see, __Turing Machine in TOC____.__