914 questions
0
votes
0
answers
46
views
Feasibility of using product DFA to show two sets are disjoint
I have two finite sets of strings S_1, S_2 that are described by DFAs (e.g. these sets are regular languages, but I want to emphasize the fact that they are finite of known maximum length).
I need to ...
3
votes
1
answer
73
views
Applying simplification rules to a DFA to derive a regular expression for it [closed]
I'm given this deterministic finite automaton (DFA):
I have to construct a regular expression for it. I do not understand one thing in the method described in my handbook.
First of all, we have to ...
0
votes
0
answers
25
views
What is it called to rule out a substring from matching a regex
I will start with specific examples since I lack the term I am looking for.
Let's start with the regex [^x]xyx[^x].
The regex matches string abcxyxdef. The regex begins to match string abcx, and might ...
-1
votes
1
answer
59
views
Regex for c++ for loop conditions
There's no better way of explaining than with an example:
say I have a for loop:
for(int i = 0; i<n;i++){
I basically want a regex that groups i = 0, i<n, and i++ into three separate groups.
...
-3
votes
1
answer
163
views
Are my DFA's correct? (arbitrary long sequence of 0's and 1's) [closed]
For my exercise I'm supposed to create two DFA's.
The task specifically is:
Construct a DFA over the alphabet Σ={1,0} accepting the following regular languages.
a) An arbitrary long sequence of zeros ...
-1
votes
3
answers
228
views
Regular expression for the language: All words over {a,b,c} such that #a(w)>=2 and #b(w)>=2
Seeking help with a regex task: Constructing a pattern for words over {a, b,c} with #a(w)≥2 and #b(w)≥2
c has no limitations
. Need solution assistance.
example for words that are in the language:
...
0
votes
1
answer
276
views
Regex with even instances of ab and ba
I am trying to write a regex to match strings with even instances of ab and ba with only the alphabet of {a,b}.
I am trying to do so with only | and * operators. I think it has something to do with ...
1
vote
1
answer
46
views
Text between two characters
I'm trying with regular expression to select text between two () characters, complete with characters included.
EX. Text (the text) -> (the text)
EX2. Text text text (the text again) -> (the ...
3
votes
1
answer
1k
views
Regular expression for L = {w|w doesn't contain the substring 110} over the alphabet Σ = {0,1}
Consider the language L = {w|w doesn't contain the substring 110} over the alphabet Σ = {0,1}
Write the regular expression
Currently I have the regular expression as 0*(10*10)*1*
But the autograder ...
0
votes
1
answer
434
views
Regular expression of "odd number of a and odd number of b"
I want to create a regular expression of odd lengths of a and b. I found this solution on Stack Overflow:
((a+aaa)*(b+bbb)*(a+aaa)*(b+bbb)*(a+aaa)*)*(ab+ba).........
I found it to be correct from ...
2
votes
2
answers
245
views
Correct labeling for this regular language?
So I am a newbie computer science person and would like some help from the community in helping me understand this subject.
I have this regular language I am trying to determine is 3 things from this ...
0
votes
1
answer
272
views
How to use JavaScript's sql-formatter library to parse a SQL statement that contains the nested concat function in the where condition
I want to implement a formatted SQL function on the front end. Among them, SQL may contain some mybatis-specific syntax, such as '#{var}'.
The input is SQL compressed into one line; the output is ...
-1
votes
1
answer
55
views
how to prove {(a^m)(b^n)(c^k): m!=k and m,n,k ∈ N} is non-regular?
It's a question in CS courses "Theory of Computation", about proofs of regular or non-regular language.
How to prove {(a^m)(b^n)(c^k): m!=k and m,n,k ∈ N} is non-regular?
I try to solve it ...
-1
votes
1
answer
229
views
Jenkins - To trigger pipeline only for event failed or successful for jenkins webhook trigger
I want to trigger a pipeline for cases where it only triggers two cases when the event received is failed or successful using the Jenkins webhook trigger.
enter image description here
for eg: If I ...
0
votes
3
answers
147
views
How to write a generical REGEX expression to: Σ = {a, b, c}, L = {w ∈ Σ ∗ / the first symbol of w is equal to the last symbol of w}? [closed]
I tried ^(a|b|c)?(a|b|c)*\1$ and some variations but for some reason words like a or b aren't captured. Could you guys explain me why?
I also don't get why in the expression ^(a|b|c)?(a|b|c)\1$ the ...
5
votes
2
answers
721
views
How can I allow a single space in a regex in Dart but allow other characters to be 1 or more?
I've looked through tons of stuff and all point to just add a space in the regex but it doesn't work for me, can you explain why and how can I make it work?
Right now the expression I am using is this ...
0
votes
0
answers
21
views
How remove numbers from url using RewriteRule in .htaccess file? [duplicate]
I want to Rewrite my url using .htaccess file using php as I got hundreds of url's like this and I don't want to add individual RewriteRule for these many url's.
I want to remove numbers from start of ...
0
votes
0
answers
23
views
How do the kleene plus operators apply here? [duplicate]
(cd+)+?
I have cd+ to {cd, cdd, cddd, ...} but I do not understand how to apply the + from the parenthesis.
I saw that if it is like (d*)* then it is same as d* but here its not just d* in it but c ...
1
vote
1
answer
2k
views
Automata theory: Formal definition of indistinguishable & distinguishable strings and example confusion
In automata theory, we can use Myhill–Nerode theorem to prove that a language is not regular.
The theorem makes use of the concept of distinguishable and non-distinguishable strings.
While it is ...
0
votes
2
answers
105
views
Accept an optional substring with Lark's LALR(1) parser
I would like to use Lark to generate a standalone parser for a small rational language of mine. This needs to be a LALR(1) parser.
It should accept the following input:
(lorem) consectetur adipiscing ...
0
votes
0
answers
54
views
Match bitwise operators in lex
I am implementing the lexical and syntax analyzer for a c++ like programming language
I have the following line in the regular expressions' section in lex file
arithm_op [/+*%-]
bitwise_op [...
1
vote
1
answer
27
views
Regular expression without "Double or more" spaces
I need a regular expression that allows:
You cannot put a space at the beginning and end of a line
There can only be one space between words
I had enough for something like "^[АЯ-Ёа-яё0-9' ']+$&...
0
votes
1
answer
211
views
what is the Context-Free Grammar for the following language?
Here is the language and I want to create a context-free grammar for it:
b(bc+a)*a(a+b)*c*
Here is my answer but I don't know if it's right or not:
S → bAaB
A → bcA | aA | epsilon
B → cB | aB | ...
1
vote
1
answer
522
views
Split a string by punctuation marks (.!?;:) while excluding abbreviations
I'd like to create a function that's capable of splitting a string containing multiple sentences by dots, but at the same time handles abbreviations. For example, it shouldn't split after "Univ.&...
1
vote
3
answers
209
views
Regex - Match lines that contain at least 2 vowels
I want to find all lines that contain at least two vowels.
I tried to use the sentence: .*[aeiou].{2,}\n
But it seems that it doesn't succeed, in this failed result it still contains even lines with ...
2
votes
0
answers
175
views
Finding Myhill-Nerode relation to get equivalence classes
Fix strings x and y, |x| < |y| = n. For any 2 strings of different lengths, there is a DFA with O(logn) states that accept x and rejects y. Prove that this DFA exists.
My approach: I tried to find ...
0
votes
1
answer
150
views
Can we transfer every DFA to DFAs with start state having no in edge?
The start state cannot have any "in edge" (an arrow point directly to the start state) and only out edge is possible for the start state. Other states except the start state are free of ...
0
votes
2
answers
178
views
How can I represent the regular language ∑={a,b,c} with a regular expression in such a way that two characters 'b' cannot be next to each other?
The alphabets of a regular language are ∑={a,b,c}
I need create regular expression for:
a.) Accepts strings that do not have two 'b' characters next to each other.
example: aabccbaaccb <- allowed
...
0
votes
1
answer
91
views
Can this language be expressed with a regular expression?
The given language is:
B = { aibic2m | i ≥ 0, m ≥ 0 } ∪ { arbsc2t | r ≥ 4, s ≥ 4, t ≥ 0}
My Prof has provided a regular expression for this language which is:
a4a* b4b* (c2)* + (epsilon + ab + a2b2 + ...
0
votes
0
answers
189
views
Is there any way to count the production of specific rules in order in a context free grammar?
Is there any way to use a counter in context-free grammars?
I need to add a module number (for example starting from M1:0, M1:1, ... , M1:K representing the module number) and I want to count every ...
2
votes
1
answer
462
views
Using string of set length with pumping lemma to prove irregularity
There is this proof that I thought of that I am not quite sure if it's valid or not.
Suppose you had to prove the nonregularity of the following language:
A = { 0^n 1^n 2^n | n>= 0 }
The proof I ...
2
votes
1
answer
685
views
Closure property of regular languages under concatenation and star operation
In our course of Theory of Computation, we have done the proof for closure of
regular languages(L1, L2) under intersection, union and complement. But their closure under concatenation(L1L2) and star(...
1
vote
1
answer
563
views
How to generate an Unrestricted grammar if a language defination is given
How to construct unrestricted grammar that generates L = {a^ib^j c^k^d^l : i not equal to k AND j not equal to l}.
a is to the power of i, 'b' raised to the power of j, 'c' raised to the power of k, '...
0
votes
1
answer
41
views
Regular expression for the following condition
Define a regular expression for the alphabet {a,b} where subsequences of a's that aren´t empty are always even and subsequences of b's are always odd.
I have something like this but I think it works ...
1
vote
1
answer
76
views
Checking a string with a regular expression
The expression allows me to capitalize the first letter, then I put the continuation of the word and tell it that I only allow small case characters and do not limit their number.
I expect it to ...
-1
votes
1
answer
611
views
Let L be a language over {a,b} that contains the same number of occurrences of a and b. Which of the following language is regular?
(https://i.sstatic.net/lU278.png)
Why option C is also not correct?
2
votes
1
answer
862
views
Given a binary alphabet {0,1}, write a regular expression that recognises all words that have an even number of ’1’s and starts and ends with a ’0’
I'm working through some exam questions for a module in college. I've been asked to create a regular expression that recognises all words that have an even number of ’1’s and starts and ends with a ’0’...
2
votes
2
answers
1k
views
Validating a url path with regex and excluding special characters
I'm trying to write up an expression that starts with a '#" and takes in the following types of paths and only takes in a character A-z/a-z and doesn't accept digits or special characters:
...
0
votes
0
answers
38
views
regular expression match methods with python
There is a string text
<R-PORT-PROTOTYPE>
<SHORT-NAME>VtDBGO_ReMotTqReqL2_null</SHORT-NAME>
<REQUIRED-COM-SPECS>
<NONQUEUED-RECEIVER-COM-SPEC>
<DATA-...
-2
votes
1
answer
68
views
Explain regular expression in Python
Can you help me to understand this code line by line please?
def word(w)
pattern = re.compile(r'^[^aeiouAEIOU]+')
if re.findall(r'[^aeiouAEIOU]y[^aeiouAEIOU]', w):
pattern = re....
0
votes
3
answers
533
views
Regular expression to identify a python function body and locate all the executable lines (ie non-comments)
I have a file that is a python code (may not be syntactically correct).
It has some functions which are commented out except the signature.
My goal is to detect those empty functions using a regex and ...
2
votes
3
answers
548
views
R to detect accent
Is there a way using grepl or another function to detect all words that have accent? Not ignoring it, which has been ask many times, just to detect all the words that have any accent in it.
Thanks
-1
votes
1
answer
161
views
Why doesn't {a^nb^n | n >= 0} follow regular language closure properties?
Using the pumping lemma, we can prove that {a^nb^n | n >= 0}, but what is not clear is the following.
{a^n | n >= 0} is regular by itself and so is {b^n | n >= 0}, and if I am not mistaken, ...
0
votes
0
answers
256
views
Can someone help me with this proof about the pumping lemma using coq?
This is an exercise from software foundation.
I have proved weak pumping lemma, but I don't know how the prove the strong one.
When I try proving the third case 'App', I can't deal with length (s1 ++ ...
0
votes
1
answer
596
views
Why is L = {a^ib^i , 0<i<5} regular?
I am trying to understand regular languages. I found this question here https://www.sanfoundry.com/automata-theory-multiple-choice-questions-answers/
Is L = {a^i b^i | 0<i<5} regular?
The answer ...
1
vote
1
answer
433
views
why regular expression match result is empty
this is code
#include <iostream>
#include <regex>
using namespace std;
static void search_by_regex(const char *regex_s,
const string &s)
{ // ①
regex ...
0
votes
0
answers
45
views
Specification of DFA accepting 𝐿≡∪𝑛∈N𝐿𝑛
Why it is impossible to specify a single DFA that accepts 𝐿≡∪𝑛∈N𝐿𝑛, although an individual machine can be constructed for each 𝑛?
0
votes
3
answers
122
views
Combining regex to retrieve match cases
I have the following string
[1] weight | width | depth | 5.0 cm | 6.0 mm^2 | 10.12 cm^3
From that I need to extract the name, value and units from the above string like below
name = weight
value = 5....
0
votes
2
answers
141
views
Extract strings followed by number with space using regex
I have the follwing string
[1] weight | width | depth | 5.0 kg | 6.0 mm^3 | 10.12 cm^2
From that I need to extract the unit strings only
unit=kg
unit=mm^3
unit=cm^2
I tried the below regex
(?<...
0
votes
2
answers
71
views
regular expression to met length firstly then check other pattern?
I don't know how to express the question in English title exactly, there are 2 rules
firstly, met the given length as long as possible on the head and end part
then match the other pattern
for ...