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
0
votes
1 answer

Transformation from DFA to regular expression

What is the correct regular expression for this DFA? I came up with the solution 0|1(0(0|1))*1* The problem with my solution is, that it's not possible to use the q2->q2 and then loop through q1 and q2. The correct answer according to the paper…
Robert
  • 21
0
votes
1 answer

Regular Expression question Σ = {a, b}, what's the expression containing either ba or abb?

So Σ = {a, b}, I need to find a regular expression representing all strings that contain either ba or abb. Here's what I got, but I wonder if it's correct. (ab)(baUabb)(ab)(baUabb)(ab)* It seems to be that it's a bit too long. Would appreciate any…
0
votes
2 answers

Superscript in regular expression

If I want a language where the entries are in the form of $\gamma A^{n+2}\gamma A^{n+2}...\gamma A^{n+2}$, is it possible to write a regular expression as $(\gamma A^{n+2})^*$, or is it weird to have that '$n+2$? The languages are different for each…
MNSAR
  • 5
0
votes
1 answer

Confusing about regular expressions.

I am new to regular expressions. Hence, it is a bit confusing to me. If I have a regular expression such that $(AAAA^{*}X)^{*}AAAA^{*}$, does $g=AAAAXAAAXAAAAXAAA$ can be one of the expressions? Also, which of the following is the correct way to…
MNSAR
  • 5
0
votes
2 answers

Regex with at least three even digits and odd length

As the title said, I need to make a regex for a number with at least three even digits and odd length. As an example, the number 248 should match. Thank you!
Carl J.
  • 43
0
votes
1 answer

Help with Regular Expression

How would you write a regular expression that matches exactly the strings over the alphabet {A, . . . , Z} that contains the letter "O" only if they contain the letter "I" and contain at most two "E"’s.
0
votes
1 answer

Consider the following two finite automata. accepts and accepts . Which one of the following is TRUE?

My Approach: Using Ardens Theorem I got these Regular Expressions M1 Regular Expression R1: $(0+10)\*11(0+1)\*$ M2 Regular Expression R2: $(0+1)\*11(0+1)\*$ Answer is L1=L2 How Can we Prove That R1 generate the Same language as R2?
0
votes
2 answers

regular expressions and words in the language

Consider the regular expression ((AB)* (C(A*) |B))* Give three words (over the alphabet {A,B,C}) that are in the language of this expression, and three that are not (and label them accordingly). Translate the language into an NFA. I got ABABCAAB,…
yvvy19
  • 1
0
votes
1 answer

Regular expression of length n divisible by 2 or 3

I have an alphabet $\sum=\{o,g\}$ and I need to write a regular expression for arbitrary sequences of length $n$ where $n$ is divisible by 2 or 3. My guess would be [og][og]* | [og][og][og]*, but I am not certain if this is correct or incorrect.
0
votes
0 answers

Writing a regular expression to represent a set using Kleene stars

Here's the question: Let Σ = {a, b, c}. Write a regular expression for the set of all strings in Σ* (the * represents a Kleene star) such that the sum of the number of a’s and b’s in the string is at most two. Thus the string can have an a and a b…
0
votes
1 answer

Regex for bit string containing at least 2 zeros but no consecutive zeros.

This is what I have: (1*011*011*)* But I don't think this is accounting for an odd number of zeros, like "10101010101111". I think I have the right expression that satisfies no 2 consecutive zeros and even number of zeros.
0
votes
0 answers

Regular set definition

I came across the following regular sets definition: Let Σ be a finite alphabet. Regular sets over Σ are defined recursively as follows: ∅ (i. e. an empty set) is a regular set over Σ, {ε} is a regular set over Σ, {a} is a regular set over Σ for…
Milda
  • 1
0
votes
1 answer

Is $(r^*)^* = r^*$?

If $r$ is a regular expression, is it always true that $(r^*)^* = r^*$? I've been trying to come up with simple examples and to me it seems like the answer is yes but I'm not quite sure. How would I justify this?
John
  • 1
0
votes
1 answer

Mathematical expression of the number of names fulfilling the condition

I have an example where a total of 2200 names are entered. Each name has an assigned percentage value from 0% to 100%. The total number of names with a value above 88% is 459. I need to formulate this in a mathematical way in a formula that will…
0
votes
1 answer

regular expression and intersection

I have this language L that contains only one string: $a_{1}a_{1}a_{2}a_{1}a_{1}a_{2}a_{3}a_{1}a_{1}a_{2}a_{1}a_{1}a_{2}a_{3} ....a_{n}...a_{n}$ written more concisely $(..(a_{1}^{2}a_{2})^{2}a_{3}^{2}..)^{2}$ I am asked to find the length of the…
Jiyda Moussa
  • 239
  • 2
  • 11