I try to use NFA to implement a negate regex.
I know that NFA can easily combine regex like ab a|b and a*
and the variety [ab] can convert to a|b
but how can I convert [^ab] to a NFA fragment?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is just a character class. The transitions of NFAs are labeled with single characters or lambda (the empty string). To implement a character class, just have a transition for each character in the class. The negated class is just implemented with one transition for each character not in the class. Since the NFA is required to have a finite alphabet, this is no problem at all. If A is the alphabet and you want [^ab], then you need one transition for each character in the set A – {a, b}.