Hi,
The usual way to represent way the grammar associated with a textual network protocol is using ABNF.
Just like any EBNF-related meta-syntax, ABNF enables to describe context-free grammars.
These context-free grammars can represent a non-regular language, right ?
The usual way to implement a network stack is developing a state ma...
I'm working on some homework for my compiler class and I have the following problem:
Write a regular expression for all strings of a's and b's that contain an odd number of a's or an odd number of b's (or both).
After a lot of whiteboard work I came up with the following solution:
(aa|bb)* (ab|ba|a|b) ((aa|bb)* (ab|ba) (aa|bb)* (ab|ba...
How can I write a regular definition in (f)lex for quoted strings from AT&T language?
Example of string that come to my mind:
"abc"
"a\"bc"
"abc\"
"abc\""
Later edit:
"abc" "def" should be matched as two strings
"ab\"c" "def" should be matched as two strings
"abc\" "def" should be matched as two strings
The definition \"[^\"]\" ...
This is more of a computer science question than a programming one, but I figure that this is the best place out of all the related sites to ask this.
When I discovered Regular Expressions and looked up the term I assumed that this property of "regularity" refers to the fact that the expression's language has a definable structural pat...
In a CS course I'm taking there is an example of a language that is not regular:
{a^nb^n | n >= 0}
I can understand that it is not regular since no Finite State Automaton/Machine can be written that validates and accepts this input since it lacks a memory component. (Please correct me if I'm wrong)
The wikipedia entry on Regular Lang...
Trying to parse an SQL string and pull out the parameters.
Ex: "select * from table where [Year] between @Yr1 and @Yr2"
I want to pull out "@Yr1" and "@Yr2"
I have tried many patterns, but none has worked, such as:
matches = Regex.Matches(sSQL, "\b@\w*\b")
and
matches = Regex.Matches(sSQL, "\b\@\w*\b")
Any help?
...
What is the regular expression for the language 0m1n where m+n is even?
...
Given the language below, how do i find a regular expression for the language
L = {a ^n b ^m | n => 1, m =>1, nm =>3}
...
In my regex, I want to say that within the sample text, any characters are allowed, including a-z in upper and lower case, numbers and special characters.
For example, my regular expression may be checking that a document is html. therefore:
"/\n<html>[]+</html>\n/"
i have tried []+ but it does not seem to like this?
...
lets say i use jquery.get to retrive a website to string and how am i gonna select the whole table with class=product from it? $() seem cant work on string ....
...
I'm reviewing some notes for my course on Theory of Computation and I'm a little bit stuck on showing the following statement and I was hoping somebody could help me out with an explanation :)
Let A be a regular language. The language B = {ab | a exists in A and b does not exist in A*}
Why is B a regular language?
Some points are obvi...
Most UNIX regular expressions have, besides the usual *,+,? operators a backslash operator where \1,\2,... match whatever's in the last parentheses, so for example L=(a)b\1* matches the (non regular) language a^n b a^n
On one hand, this seems to be pretty powerful since you can create (a*)b\1b\1 to match the language a^n b a^n b a^n whi...
If you're given a language, how do you figure out if it's regular, CF but not regular, or phrase-structure but not CF? Is there a good way to attack this problem? I could randomly try to make FAs or PDAs, but I feel like there's a better way to do it.
Classic example:
L = { a^n b^n c^n | n >= 0 }
Where would one start?
Thanks.
...
Good Day,
I have tried, and burned my brain to understand the definition of Regular Languages in Discrete Mathematics and its Applications(Rosen) without reaching the goal of understanding why the definition is like that in this book. On page(789), I am rephrasing the definition:
Type 3 grammars are defined as:
w1 --> w2
Where w1 is...
Is it possible to detect if a given string is valid regular expression, using just regular expressions?
Say I have some strings, that may or may not be a valid regular expressions. I'd like to have a regular expression matches those string that correspond to valid regular expression. Is that possible? Or do I have use some higher level ...
Hi,
I'm trying to use Ragel to implement a simple yes/no fsm. Unfortunately the language specification consists of the union of about a thousand regular expressions, with * operators appearing once or more in the majority of them. So, the number of possible states explodes and it seems it will be impossible to use Ragel to generate an f...
I apologize in advance for my primitive english; i will try my best to avoid grammatical errors and such.
Two weeks ago i decided to freshen my knowledge of Scheme (and its enlightnings) whilst implementing some math material i got between hands, specifically, Regular Languages from a course on Automata theory and Computation in which ...
Give an FA for the set of the strings with alphabet {a,b} that contain both or neither aa and bb as substrings.
It means FA accept all strings without aa and bb as substrings. correct me if I wrong and give me some hint. Thanks all. :D
...
Hello,
After having read up on RE/NFA and DFA, it seems that finding a substring within a string might actually be asymptotically faster using an RE rather than a brute force O(mn) find. My reasoning is that a DFA would actually maintain state and avoid processing each character in the "haystack" more than once. Hence, searches in long...
Most languages allow fixed-length or finite-length lookbehind. One notable exception is .NET, which allows the use of the * operator.
However, .NET regexs can already recognize balanced parentheses using named capture, which is not a regular language. Are regexs still regular with * in lookbehind? Extended answers for subexpressions ...