Categories of Regular Expressions
Category 1: Basic Regular Expressions
| Sr. | Regular Expression | Explanation |
|---|---|---|
| 1 | a | Only a single character "a". |
| 2 | ab | Sequence "a" followed by "b". |
| 3 | (a+b) | Either "a" or "b". |
| 4 | (a)* | Zero (ε) or more occurrences of "a". |
| 5 | (ab)* | Zero (ε) or more repetitions of the sequence “ab". |
| 6 | (a+b)* | Zero (ε) or more symbols from the alphabet {a,b} of any length, any order. |
| 7 | (a)+ | One or more occurrences of "a". |
| 8 | (ab)+ | One or more repetitions of the sequence "ab". |
| 9 | (a+b)+ | One or more symbols chosen from "a" or "b". |
| 10 | (10+1)* | Zero (ε) or more repetitions of "10" or "1". |
| 11 | (01+10+1)* | Zero (ε) or more repetitions of "01", "10", or "1". |
| 12 | (a+b+c+d)* | Zero (ε) or more symbols chosen from "a", "b", "c", or "d". |
| 13 | (a+b+c+d)+ | One or more symbols chosen from "a", "b", "c", or "d". |
| 14 | (ab+bb+cc+dd)* | Zero (ε) or more repetitions of "ab", "bb", "cc", or "dd". |
| 15 | 101 + (0+1)*1 | Either "101" or any combination of 0s and "1s” ending in "1". |
| 16 | 11 + 00 + 0 + 10* | Either "11", "00", a single "0", or "1" followed by zero or more "0s”. |
| 17 | 1(0 + 11) + 0(00 + 1) | Either "1" followed by "0" or "11", or "0" followed by "00" or "1". |
| 18 | ba + (aa + b)* | Either "ba" or any number of repetitions of "aa" or "b". |
| 19 | aa + ba + (aa + b)* | Either "aa", "ba", or any number of repetitions of "aa" or "b". |
| 20 | (00)*(0 + 1) + (1)* | Zero (ε) or more "00"s followed by 0 or 1, or any number of "1s”. |
| 21 | (001)* + (00) | Zero (ε) or more repetitions of "001", or exactly "00". |
Category 2: Start with Regular Expressions
| r. | Regular Expression | Simple Explanation |
|---|---|---|
| 1 | a(a+b)* | Starts with a, followed by any number (even zero) of as or bs in any order. |
| 2 | 101*(0+1)* | Starts with 10, then zero or more repeats of 1, then zero or more mix of 0s and 1s. |
| 3 | bab(a+b)* | Starts with bab, followed by zero or any number of as or bs . |
| 4 | aa(aba+bab)* | Starts with aa, followed by zero or any number of the patterns aba or bab. |
| 5 | (a(bb)*)(a+b)* | Starts with a, then zero or more bbs, then zero or any number of as or bs in any order. |
| 6 | 1(0+1)(00+11)* | Starts with 1, then either 0 or 1, then zero or more repeats of 00 or 11. |
| 7 | a+b+c(ab+bb+cc)* | One"a", One “b”, or starts with"cand then zero or more repeats of ab, bb, or cc patterns. |
| 8 | a+b+c+d(ab+bb+cc+dd)* | One"a", One “b”, One “c” or starts with"dand then zero or more repeats of ab, bb, cc, or dd patterns. |
| 9 | aba(a+b)* + bab(a+b)* | Either starts with aba or bab, followed by zero or any number of as or bs |
Category 3: End with Regular Expressions
| Sr. | Regular Expression | Simple Explanation |
|---|---|---|
| 1 | (a+b+c+d)*ab | Any mix of a, b, c, d (including empty), ending with ab. |
| 2 | (aaa+bbb)*ba | Repeats of aaa or bbb (or none), ending with ba. |
| 3 | (a+b+c)*abc | Any mix of a, b, or c (including empty), ending with abc. |
| 4 | (0+1)*101* | Any mix of 0s and 1s, followed by 10, and then any number of 1’s. |
| 5 | (a+b)*a(a+b)b | Any mix of a and b, then an aa or ab,and ending with b. |
| 6 | (00+11)*1(0+1) | Repeats of 00 or 11 (or none), followed by 1, and then either 0 or 1 |
Category 4: Start and End with Regular Expressions
| Sr. | Regular Expression | Simple Explanation |
|---|---|---|
| 1 | 1(1+0)*1 + 0(1+0)*0 | Strings that start and end with 1 or start and end with 0, and mix of 0, 1 in between |
| 2 | 11(0+1)(00) | Starts with 11, then either 0 or 1, and ends with 00. |
| 3 | 00(11)*101 | Starts with 00, followed by any number of 11's, and ends with 101. |
| 4 | aba(aa+b)*ba | Starts with aba, followed by any number of aa or b, and ends with ba. |
| 5 | b*(aaa+bbb)*ba | Any number of bs, followed by any number of aaa or bbb, and ending with ba. |
| 6 | a(a+b)*ba + a | Either just a, or starts with a, followed by any mix of as and bs, and ends with ba. |
| 7 | 0 + 1(0+1)*10 | Either a single 0, or a string starting with 1, then anything over 0,1, and ending with 10. |
| 8 | (11)*(0+1)(00) | Repeats of 11, followed by either 0 or 1, and ending with 00. |
| 9 | (1)*(0+1)*(00)* | Any number of 1s, followed by any combination of 0s and 1s, followed by any number of 00s. |
| 10 | 10(101+0+1)*1 | Starts with 10, followed by any number of 101, 0, or 1, and ends with 1. |
| 11 | ac(a+b+c)*ba | Starts with ac, then any mix of a, b, or c, and ends with ba. |
| 12 | d(a+b+c)*bad | Starts with d, then any mix of a, b, or c, and ends with bad. |
| 13 | acd(a+b+c)*bad | Starts with acd, then any mix of a, b, or c, and ends with bad. |
| 14 | bb(a+b)*aa(aa+bb) | Starts with bb, followed by any mix of as and bs, then aa, and ends with either aa or bb. |
| 15 | (aa+bb)((aa)*+b)*ba | Starts with aa or bb, followed by any number of aas or bs, and ends with ba. |
Comments
Post a Comment