Questions tagged [regular-expressions]

Regular expressions or Regex is a search pattern for strings defined by a sequence of characters.

A regular expression (shortened as regex or regexp) is a sequence of characters that specifies a search pattern. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory. The phrase regular expressions, or regexes, is often used to mean the specific, standard textual syntax for representing patterns for matching text, as distinct from the mathematical notation described below. Each character in a regular expression (that is, each character in the string describing its pattern) is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

673 questions
7
votes
2 answers

How can concatenating empty sets (languages) result in a set containing empty string?

In the book "Introduction to the Theory of Computation" by Michael Sipser, in the section 1.3 Regular Expressions: The symbol ε represents the emty string, which may be a valid element of a language: L = {ε}. The symbol ∅ represents an empty set; a…
7
votes
1 answer

Is one regular language subset of another?

Let $L_1$ and $L_2$ be two regular languages given as regular expressions (in this type of tasks it often happens that $L_1 \subseteq L_2$, but vice versa it is false). Is there a nice way to prove that $L_1 \subseteq L_2$ ? If yes, than do you…
6
votes
1 answer

How to write a regular expression?

I am trying to write a regular expression for the set of all strings in $\Sigma^*$ that starts with an even number of $b$'s and contains at most two $a$'s. The language contains only $a$'s and $b$'s. This is what I have figured out so far: $b^*$ -…
Sarah
  • 263
5
votes
4 answers

How does one show that these two expressions are the same?

I tried to compute the value of $\sin 75^\circ$ using the sine of standard values $(30^\circ, 45^\circ...)$ and did it by two ways. One, by expanding $\sin (45^\circ+30^\circ)$ and the other by computing the half of $\sin 150^\circ$ using basic…
Alraxite
  • 5,647
4
votes
1 answer

Regular expression for language

Let's have a language $L=\{\omega\in\{a,b,c\}^* | \omega $ contains $ab$ and does not contain $ba\}$ make a regular expression for this language. I've ended up with this one $$(a^*(b^*+(cc^{*}a^*))^*)^*ab(b^*+(cc^{*}a^*))^*$$ Is this correct? Does…
Noturab
  • 497
4
votes
1 answer

Regular expressions with empty set/empty string

I was wondering if expressions such as: $λ*$ $∅*$ $λ+∅$ $∅λ$ are considered valid expressions. If so, how can I explain them? also if $∅λ$ is valid, does that imply $∅λ∅λ∅λ∅λ∅λ∅λ$ is valid, or $∅∅∅∅∅∅∅∅∅λ$ is also valid for example.
3
votes
1 answer

Intersection / Union of two regular expressions

Is there a way to directly form a new regular expression when given two regular expressions and the desired operation (Union or Intersection). $$ (a+b)^*aa(a+b)^*\cup (a+b)^*aa(a+b)^* $$ $$ (a+b)^*aa(a+b)^*\cap (a+b)^*aa(a+b)^* $$ Without building…
Nouse
  • 33
3
votes
1 answer

Number of distinct strings in regular expression

Given the regular expression (1 + $\epsilon$ + 0 )(1 + $\epsilon$ + 0 )(1 + $\epsilon$ + 0 )(1 + $\epsilon$ + 0 ), how many distinct strings would this evaluation produce? How is the word "distinct" interpreted within the regex context? Could you…
xupv5
  • 133
2
votes
2 answers

Regular Expression Notation

I'm doing a theory of computation course and can't for the life of me find any good resource that will tell me how a regular expression such as (a+b)* converts to set form. I've thought of a binary one that I might be able to answer if I find this…
2
votes
0 answers

Regular Expression For Set of Strings Not Containing OOO

The following is my attempt at coming up with a regular expression for the set of binary strings that do not contain $000$: $(1 + 01 + 001)^*(\epsilon + 0 + 00)$ I'm going to need it for a proof. So, I'd like to know if it is correct before…
EggHead
  • 667
2
votes
2 answers

Regular expression of the strings over {1,0} where all 11 occur before all 00

I need to find a regular expression of the strings over {1,0} where all 11 occur before all 00. I found the case where there is no 00's and where a 11 has to occur before a 00. But I can't figure out how to make all 11's occur before all 00's
2
votes
1 answer

+ (plus) notation in regular expression

I'm a student learning regular expression. today while studying I saw the question Regular expression (A*B*)* = (A+B)* proof. for me + notation means one or more, while * means zero or more. So $(A^*B^*)^*$ accepts $A$ but $(A+B)^*$ doesn't because…
Peyman
  • 679
2
votes
0 answers

How can we derive 01* from 0+01*?

I am currently learning about regular expression and has recently found this question: Applying algebraic laws for regular expressions to demonstrate how 01* can be derived from 0 + 01*. My answer is: 0+01* = 0(ε+1*) Multiplying 0 by ε gives you…
2
votes
1 answer

Equivalence of regular expression

Let $ A = \{a,b\}$ be an alphabet. Please hint me with show, that this regexes are equivalent. That means, we should show that: $L(e_1 )= L(e_2)$ 1) $(a^*b)^*a^* = (a+b^*)^*$ 2) $(a+b^*)^* = (a^*b^*)^*$ $+$ means or.
user180834
  • 1,453
2
votes
1 answer

Find regular expression for a given language

I need to find a regular expression for the following language: $$ \Sigma = {\{a,b,c}\} $$ define $L$ to be the language of all words over $\Sigma$ that contain the substring $aba$ odd number of times. Any help is welcome, I would also like a tip of…
Genadi
  • 381
1
2 3 4 5 6