Questions tagged [regular-language]

Regular language is a language which can be represented by a regular expression and thus every string in the language can be accepted by the corresponding deterministic finite automaton. Note: Regular Language should not be confused with Regular Expressions. For question regarding pattern matching within strings, use the [regex] tag instead.

regular-language
Filter by
Sorted by
Tagged with
1 vote
3 answers
805 views

Regex to mask multiple phone numbers (~) separated except last 4 digiits

I am trying to find a regex which masks phone numbers except last 4 digits. example: phone=9988998888~7654321908~6789054321 Desired output : phone=******8888~******1908~*****4321 I tried below regex ...
Manoj kumar's user avatar
2 votes
0 answers
63 views

Operating on a Regular Expression before applying Pumping Lemma

When applying the pumping lemma to prove that a language is irregular, is it allowed to start by operating on the language to make applying the pumping lemma easier? For example, when attempting to ...
Zak Vanstrom's user avatar
0 votes
1 answer
59 views

How to handle "except" in Regular Expression in Compiler Design?

I'm working on Compiler Design and can't figure out how I can handle except statements in RE. For example: An RE of a literal having only 3-digit binary numbers except (011,001,010) I know that the RE ...
Qasim Khan's user avatar
0 votes
1 answer
39 views

Unable to fugure out the Regular Expression of the following

I've been working on Compiler Design lately and found Regular Expression quite tricky. So I am making a lexical analyzer for which I need lexical specification. I'm unable to figure out the RE of ...
Qasim Khan's user avatar
0 votes
1 answer
328 views

Regular expression for processing European numbers and vice versa

I am trying to find a simple way of working with numbers in my app that works with European numbers, which is turning out to be more complicated than I thought. According to the European number format,...
wl2020's user avatar
  • 75
1 vote
0 answers
135 views

Formal Language Theory - Unique "leftmost" and "rightmost" derivation tree

I'm studying Formal Language Theory and doing the exercises assigned to me, I found this question that I can't give a certain answer to: When, in general, in a context-free grammar are the leftmost ...
Giuseppe's user avatar
  • 540
0 votes
1 answer
269 views

Show is not regular with pumping lemma

I need help on this pumping lemma case: L_1 :={a^n b^m c^k | n = m or k = 0} Can someone explain how to handle k=0? I started with abc^n, but I don't know how to split this in uvw.
Saddam abi's user avatar
4 votes
2 answers
121 views

How is it possible to split a string by whitespaces, and also keep commas separate?

I would like to break up a sentence into words. If it only contains whitespaces, then .split(/\s+/) works. But how is it possible to split by comma as well, and also keep the comma in the resulting ...
Iter Ator's user avatar
  • 8,618
-1 votes
3 answers
790 views

What is the regular languages that are equivalent to the given regular language: (0 + 1)*1(0 + 1)*

I am learning automata theory. I have answered the question wrongly three times, and I don't know the right answers. Please help me. The target language is (0+1)*1(0+1)*. The choices are: A) (01+11)*(...
qwerty1s's user avatar
2 votes
1 answer
766 views

Match all except certain phrase

I found a numerous questions regard to "matching all except a single word in string". However, none of them do not work in case of phrase (two or more words combined). Suppose I have a ...
jeparoff's user avatar
  • 165
1 vote
1 answer
40 views

RegExp getting link from String except multiple www

when i try to get links from String such as "hello world https://www.sample.com/voices/2020/my-sound-www.sample.com" i get multiple link from here because i have multiple www, how can i ...
DolDurma's user avatar
  • 16.9k
2 votes
3 answers
177 views

Groupby matching pattern of different groups

I have the following dataframe: df = pd.DataFrame({'ID': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], 'Info': ['info1', 'info2', 'info3', 'info4', 'info5', 'info6', ...
Nate's user avatar
  • 209
2 votes
2 answers
60 views

Python conditional replace

I need conditional replace in string. input_str = "a111a11b111b22" condition : ("b" + any number + "b") to ("Z" + any number) output_str = "a111a11Z11122&...
Tommy Han's user avatar
0 votes
1 answer
85 views

Ragel: How to return different values by matching different expressions

I'm looking for a function that returns different integer values by matching an input string for different expressions. Here is how it could be, but syntax: package main func MatchType(data []byte) ...
Tim Wallarm's user avatar
0 votes
1 answer
71 views

Why do we use pumping lemma to prove the non-regularity of languages? WHY? [closed]

I am currently working on the usage of pumping lemma and I need to know why do we use pumping lemma? the main question asked is why? I know we can prove the non-regularity and I know the formula/proof ...
Abdul Ahad Akram's user avatar
0 votes
1 answer
40 views

How to search for specific content inside round bracktes and put it into a group?

I want to update round about 3000 sql scripts where I either have this ALTER TABLE `database_name`.`table_name` ADD INDEX `index_name` (`column_name` ASC); /* or DESC */ or this ALTER TABLE `...
user avatar
1 vote
2 answers
2k views

If L and L complement are Recursively enumerable then why can't L be a Regular language?

Below question was asked in GATE 2008 paper : If L and L' (L complement) are Recursively enumerable then L is ? a) Regular b) CFL c) CSL d) Recursive Correct option was option (d) and I accept that it'...
Avi's user avatar
  • 325
2 votes
1 answer
126 views

C grammar generates invalid expression

I am reading a book namad A Retargetable C Compiler: Design and Implementation. In this book, the C language grammar is specified like this: expression: assignment-expression { , assignment-...
kernel_panic's user avatar
-2 votes
2 answers
53 views

jQuery: Delete HTML AND unknown content/amount of plain-text between elements

Given the following HTML: <div class="date"> <span> <i class="far fa-user"></i>&nbsp;{Name} <i class="fas fa-link"></i>&...
Nintendraw's user avatar
0 votes
1 answer
22 views

How to modify this javascript highlight regex to not re-highlight itself?

I have this code: display_title = 'Example text landscapes / more text'; // highlight landscapes display_title = display_title.replace(/landscapes/gi,'<b>landscapes</b>'); // but also need ...
adrianTNT's user avatar
  • 3,834
1 vote
0 answers
386 views

Regular expression with whitelisted characters and blacklisted keywords (Google forms)

I am trying to create a Google form that accepts long answers regex data validation. I need following conditions in my RegEx: Whitelisted characters : Alphanumeric, white space, new line, and set of ...
Taeyoung Ahn's user avatar
-1 votes
1 answer
180 views

What makes this example a context-free language rather than regular language? [closed]

I'm having trouble seeing what makes "any number of a's followed by the same number of b's and c's" a context-free language, while "any number of a's followed by any number of b's ...
sonder's user avatar
  • 49
3 votes
0 answers
410 views

BNF rule to regular expression

I'm looking for a way to find out whether a specific rule in a BNF grammar can be converted to a regular expression. (With "regular expression" (RE), I mean the simple mathematical kind. I'm ...
Michael Schmidt's user avatar
-1 votes
1 answer
226 views

Can we define character class inside another character class in regular expression in python?

I want to check following conditions for a string: At least one alphabet in [a-z] At least one alphabet should be of Upper Case [A-Z] At least 1 number or digit between [0-9]. At least 1 character ...
Rahul Kumar's user avatar
-3 votes
1 answer
197 views

How to write regular expression for 16 digit ID, rules mentioned below? [closed]

I have to write regular expression in informatica data quality for 16 digit ID which should follow below set of validation. ID Must have 16 characters and follow below rules- First 6 must be ...
Yash's user avatar
  • 39
1 vote
0 answers
23 views

automate and formal laguages - prove that language is regular

I have 2 questions that I was required to tell if the language is regular or not. I have the answer so I know that the answer for both of them is true. But I don't have the intuation why and I can't ...
go vegan's user avatar
0 votes
0 answers
26 views

Is this a valid regular language expression for a binary string? Can it be condensed into something more concise?

The regular expression is: (10) U ((10(0 U 1))*10) The language I am trying to write is this:(q2 is the accept state and {0,1} is the langauge) (q0,0)=q3 (q0,1)=q1 (q1,0)=q2 — accept state (q1,1)=...
eagle37's user avatar
  • 11
0 votes
0 answers
33 views

How to add to regular expression all strange symbol for validation my product urls?

For validation utls I used this regular expression. But time to time I faced with strange symbol and I should add it to my expression, how to add all possible strange symbol to my expression ? const ...
shuba.ivan's user avatar
  • 3,924
-4 votes
1 answer
1k views

How to replace single and double digit numbers with single character in js? [duplicate]

I have an essay as a big string with letters and numbers (as page numbers) (only single digit and double digits). I want all of them to be replaced by "#". I tried str.replace(/[0-9]/g,"...
ganesh tarone's user avatar
1 vote
2 answers
147 views

Python regex: Why re.sub('a*', '-', 'abxd',count=1) = '-bxd' ? Shouldn't it be '-abxd'?

after reading the documentation for re package for python. I think that the result should be re.sub('a*', '-', 'abxd',count=1) -> '-abxd' . However, I get the following results: re.sub('a*', '-', '...
Lala James's user avatar
2 votes
1 answer
358 views

Regular expression match numbers not starting with string

I came up with a need in a regular expression for finding numbers that do not start with COM. I tried the following expression, but it does not work as expected, and the condition for COM does not ...
Anton Mikhalev's user avatar
0 votes
2 answers
129 views

Regular or context-free or other

I have a problem that needs to find out the following language is regular or context-free or other. {a^(2i+3j) | i>0, j>0} I have some doubts to say it is a regular or context-free language ...
moh's user avatar
  • 37
1 vote
1 answer
30 views

How to read language definition syntax for regular/nonregular languages

I am trying to understand a simple concept about Language definition. Specifically when there are two strings in the language definition. such as: Language F = ww | w ∈ {0,1}* Can someone help ...
Kiefer_Michael's user avatar
3 votes
2 answers
90 views

Regular expression - Python [list query]

I am trying to write a regular expression for this list: data= ["Fred is Deputy Manager. He is working for MNC.", "Rita is another employee in AC Corp."] And I want to delete all ...
Sanya's user avatar
  • 139
1 vote
1 answer
90 views

Understanding failures of recursive calls on simple proof about FSA and regular languages in Agda

I'm trying to prove that a simple FSA in Agda only accepts string which end in zero- this is the first example in Sipser's book. I didn't implement evalFSA as a predicate, but rather as function, and ...
user avatar
0 votes
0 answers
27 views

Same pattern of Regular Expression but output is different between PHP and C# .NET [duplicate]

I'm a new in PHP and .NET. Here is my question. I write the same Regular Expression in PHP and .NET. But I don't know why their countRow are different answers. I want their outputs are the same(...
peichen's user avatar
  • 31
0 votes
2 answers
705 views

Regex python find uppercase names

I have a text file of the type: [...speech...] NAME_OF_SPEAKER_1: [...speech...] NAME_OF_SPEAKER_2: [...speech...] My aim is to isolate the speeches of the various speakers. They are clearly ...
user9875321__'s user avatar
-2 votes
3 answers
91 views

check a int/string contains specific digits in it using regex

I have a string/integer X: 912035374356789 i want to check if X contains : 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 occurrence order is not matter How do check it using regular expression. if there is any ...
thenish's user avatar
  • 31
1 vote
2 answers
599 views

Use the pumping lemma to show that the following languages are not regular languages L = {anbm | n = 2m}

Use the pumping lemma to show that the following languages are not regular languages L = {an bm | n = 2m}
alaa raed's user avatar
1 vote
1 answer
140 views

Vim search pattern 'foo' but skip lines containing 'bar' without deleting any line

I want to use search and highlight in vim using pattern match. My first search criteria is to look for a string foo in a line. My second search criteria is to skip all foo if the same line contains ...
Mithun B's user avatar
  • 266
0 votes
1 answer
4k views

L={a^i b^j c^k d^l | i=k and j=l} i couldn't find the grammar of the given language

I have tried S-A|B A-aCcD|aAc|ac B-bBd|bd C-b D-d this to only to output ac and bd's but I can't put b's between a and c's.
Sevim Özsoy's user avatar
0 votes
1 answer
282 views

how to prove an arbitrary language can be accepted by an Infinite state automata

we know that language accepted by a DFA can also be accepted by an ISA for DFA is a special case of ISA, so about an arbitrary language? How to prove it?
singzhou1999's user avatar
0 votes
4 answers
454 views

Convert string representation of list of lists to list of list python without eval

I have this : x = "[['ATRM', 'SIF', 'NWPX'], ['NAV','SENEA'], ['HES','AGYS', 'CBST', 'GTIM', 'XRSC']]" x is a string. and I want this : x = [['ATRM', 'SIF', 'NWPX'], ['NAV','SENEA'], ['HES','AGYS'...
David Serero's user avatar
2 votes
1 answer
476 views

Regex contains at least one uppercase letter AND NOT contains at least one underscore

I need a regex that contains at least one uppercase and not contains any underscore, my current try out is: (?=.*[A-Z_]) I tried string like : example-chocolate-easter-egg-170g_349-85428671-...
sefirosu's user avatar
  • 2,598
0 votes
2 answers
70 views

Regular Expression with (too?) many cases

I'm struggling with a Regex since a few hours and don't seem to find the last bit of the solution. I'm basically parsing a C-Header files line-by-line to find variables. Following the possible cases ...
DonBaron's user avatar
  • 1,364
0 votes
0 answers
628 views

Is regular TM recognizable?

What I learned from theorem 5.3, we are dividing the problem into to 1)Language of all strings 2)Not all strings. Where ATM is recognizable but in case when it accepts a word ,modified TM too have to ...
Huda's user avatar
  • 1
1 vote
1 answer
464 views

Annihilator set in regular expression

Given that ø+anything is an indentity, therefore ø + a = a. What exactly is the result of (ø+ øbb)?
user avatar
3 votes
1 answer
436 views

Convert context free grammar to regular grammar

I wonder how to design this regular grammar, or how to convert my context free grammar to regular grammar (like A->aA).I tried but no result for this. Question: The set of strings on Σ ={a,b}which ...
NormalSL's user avatar
3 votes
1 answer
2k views

Regex to Detect Zalgo

I'm creating a message filtering system, that detects z͎͗ͣḁ̵̑l̉̃ͦg̐̓̒o͓̔ͥ. My current regex is /([^\u0009-\u02b7\u2000-\u20bf\u2122\u0308]|(?![^aeiouy])\u0308)/gm but this also captures emojis. The ...
ADAMJR's user avatar
  • 2,358

1 2
3
4 5
19