regular-language

Minimum pumping length for a regular language

假装没事ソ 提交于 2019-12-12 08:58:02
问题 How to calculate minimum pumping length of a regular language. For example if i have 0001* then minimum pumping length for this should be 4 ,that is 000 could not be pumped . Why it is so? 回答1: It will be less than or equal to the number of states in a minimal DFA for the language, minus one. So convert the regular expression into a DFA, minimize it, and count the states. For your example: 0001* SOURCE SYMBOL DESTINATION q1 0 q2 q1 1 q5 q2 0 q3 q2 1 q5 q3 0 q4 q3 1 q5 q4 0 q5 q4 1 q4 q5 0 q5

[af]?lex regular expression difference

陌路散爱 提交于 2019-12-12 06:39:41
问题 I don't know how to do this, and I've found no good resources online for how to perform this operation[.] I'm trying to take an annotated EBNF production rule which is a difference between two regular expressions and turn it into a(n a| f?)lex grammar specification rule[.] The problem is that I see no way to do this normally[.]{3} is there a way to do this using Kleene algebra, like the way you can use an empty match with alternation in a context-free grammar[?] 回答1: What does the EBNF

verifier of addition… not-regular, but is it context-free? [closed]

天大地大妈咪最大 提交于 2019-12-12 01:16:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . How can I show that the following language is (not) context-free? The argument that it's not regular goes as follows. I suspect this language to be context-free... The reason why I think this, is because L = {a n b m c {n+m} | n,m >= 0} is context-free. A proof for this can be found at http://cg.scs.carleton.ca/

Regular Expression for greater than date format xx-xx-xxxx

亡梦爱人 提交于 2019-12-12 00:37:21
问题 I have a single text file with 40,000 records. I need to locate all items greater than October 1st 2011. The format is 01-10-2011 - How can I do this using regular expression? 回答1: It probably shouldn't be done, but it can be done: ([0-3][2-9]|[1-3]1)-10-2011|[0-3][0-9]-1[12]-2011|[0-3][0-9]-[01][0-9]-201[2-9] This assumes all dates are DD-MM-YYYY and valid, and that you don't need to find dates further in the future than 2019, for which it could be adapted if necessary. Tested in Dreamweaver

A regular expression for the complement of the language L

随声附和 提交于 2019-12-11 18:06:09
问题 Let L(R) be the language denoted by regular expression R. I'd really love your help with presenting a regular expression to the complement of L((0 U 10 U 110)* (epsilon U 1 U 11)), where language is over the alphabet {0,1}, epsilon is the empty word, 'U' stands for union and '*' is the star iterator. I tried to find it with De Morgan's laws. I think that I am requested to evaluate not (L((0 U 10 U 110)* (epsilon U 1 U 11)))- what is not of the '*' for example? Thanks a lot 回答1: You need to

Regex: Get nth character between two delimiters

ぐ巨炮叔叔 提交于 2019-12-11 15:17:44
问题 I have an example string 1836248_NNY_01.pdf but it can also be 18362481_YYN_102.pdf And I need to get the nth character between the two underscores. So far my regex is \_(.*?)\_ to get the characters between the underscores. But following up I can't figure out how to get the 2nd N for example. https://regex101.com/r/XUMKyf/1/ 回答1: You could use \_.{1}(.).*\_ and replace the 1 with whatever you want. So 0 would be the first char, 1 the second, and so on. Example: https://regex101.com/r/XUMKyf

What is the intersection of two languages with different alphabets? [closed]

馋奶兔 提交于 2019-12-11 13:44:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I did some googling on this and nothing really definitive popped up. Let's say I have two languages A and B. A = { w is a subset of {a,b,c}* such that the second to the last character of w is b } B = { w is a subset of {b,d}* such that the last character is b } How would one define this? I think the alphabet

Is there a regular language to represent regular expressions?

半城伤御伤魂 提交于 2019-12-11 07:48:27
问题 Specifically, I noticed that the language of regular expressions itself isn't regular. So, I can't use a regular expression to parse a given regular expression. I need to use a parser since the language of the regular expression itself is context free. Is there any way regular expressions can be represented in a way that the resulting string can be parsed using a regular expression? Note: My question isn't about whether there is a regexp to match the current syntax of regexes, but whether

Understanding (and forming) the regular expression of this finite automaton

萝らか妹 提交于 2019-12-11 03:49:23
问题 For the above automaton, the regular expression that has been given in my textbook is the following : a*(a*ba*ba*ba*)*(a+a*ba*ba*ba*) I am having trouble deriving this...the following is my attempt at it : aa* + aa*(ba*ba*ba*)* + ba*ba*ba* + ba*ba*ba*(ba*ba*ba*)* Either I am wrong or I am not being able to simplify it into the form given in the book. Can someone please guide me here, point out the mistake or explain it to me step-by-step? I'd really really thankful and appreciate that. 回答1:

Show that the following set over {a,b} is regular

守給你的承諾、 提交于 2019-12-10 16:33:41
问题 Given the alphabet {a, b} we define N a (w) as the number of occurrences of a in the word w and similarly for N b (w) . Show that the following set over {a, b} is regular. A = {xy | N a (x) = N b (y)} I'm having a hard time figuring out where to start solving this problem. Any information would be greatly appreciated. 回答1: Yes it is regular language! Any string consists if a and b belongs the language A = {xy | N a (x) = N b (y)} . Example: Suppose string is: w = aaaab we can divide this