Re: regular expression question

glen herrmannsfeldt <gah@ugcs.caltech.edu>
8 Jun 2005 22:31:01 -0400

          From comp.compilers

Related articles
regular expression question gvheurn@gmail.com (Gijs) (2005-06-08)
Re: regular expression question gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-06-08)
Re: regular expression question 148f3wg02@sneakemail.com (Karsten Nyblad) (2005-06-08)
Re: regular expression question daw@taverner.cs.berkeley.edu (2005-06-08)
Re: regular expression question gvheurn@gmail.com (Gijs) (2005-06-09)
Re: regular expression question nicola.musatti@gmail.com (Nicola Musatti) (2005-06-09)
Re: regular expression question cfc@shell01.TheWorld.com (Chris F Clark) (2005-06-09)
Re: regular expression question snicol@apk.net (Scott Nicol) (2005-06-10)
[5 later articles]
| List of all articles for this month |

From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: 8 Jun 2005 22:31:01 -0400
Organization: Compilers Central
References: 05-06-045
Keywords: lex
Posted-Date: 08 Jun 2005 22:31:00 EDT

Gijs wrote:




> Don't know if this is the right group for this. Can anyone tell me how
> to create a regular expression that matches all except for one string?
> I tried to use the complement sign ^, but this is only usable for one
> character, not for a whole string.


> So for example I want to have a RE that matches all strings except for
> the string "hello". How do you do this?


(snip)


> [It's not a dumb question, it's a hard question. The complement of a RE
> is usually not a RE. My practical advice would be to look for "hello" and
> reverse the sense of the test in the surrounding code. -John]


Maybe I missed the question, but the one time this happened to me,
was in PSL, the Pattern Specification Language for
the Paracel FDF, which is a little more general than RE. I needed to
find a specific word not followed by another specific word. With the
added complication of word boundary detection, and with a RE form
that allows an OR operation, something like:


[a-gi-z] | [h][a-df-z] | [h][e][a-km-z] | [h][e][l][a-km-z] |
[h][e][l][l][a-np-z]


-- glen
[Actually, I was wrong. See subsequent messages. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.