# Re: reg expr...

## "Sarah Thompson" <sarah@telergy.com>

11 Sep 2002 23:22:36 -0400

*From comp.compilers*

Related articles |

reg expr... *shoaib@students.cs.mu.OZ.AU (Shoaib Ali BURQ)* (2002-09-08) |

Re: reg expr... *gwyn@thislove.dyndns.org (Gwyn Judd)* (2002-09-11) |

**Re: reg expr... ***sarah@telergy.com (Sarah Thompson)* (2002-09-11) |

Re: reg expr... *torbenm@diku.dk (Torben Ęgidius Mogensen)* (2002-09-12) |

| List of all articles for this month |

**From: ** | "Sarah Thompson" <sarah@telergy.com> |

**Newsgroups: ** | comp.compilers |

**Date: ** | 11 Sep 2002 23:22:36 -0400 |

**Organization: ** | http://groups.google.com/ |

**References: ** | 02-09-040 |

**Keywords: ** | lex |

**Posted-Date: ** | 11 Sep 2002 23:22:36 EDT |

*> I'm looking for a regular expression that say:*

*>*

*> match the line that does not begin with the string {s}*

*>*

*> now the way i see it ... if my s = "abc" then i will have to look for*

*> (a & b) or (ab & not c) or (abc & not wht_spc) ...*

*>*

*> but the longer the s the longer the reg expr ... is there another way to*

*> do this?*

For the case where {s} is 'fruitbat', the regex:

[^f][^r][^u][^i][^t][^b][^a][^t].*|.{0-7}

should work, assuming the whole input is one line. The first term will

match any line of 8 or more characters, where the first 8 characters

are not 'fruitbat'. The second term picks up the other possible valid

lines, which are any combination of up to 7 characters.

Using POSIX syntax for line start/end matching and assuming input

containing multiple lines, something like:

^([^f][^r][^u][^i][^t][^b][^a][^t].*|.{0-7})$

should do the trick.

Sarah

Post a followup to this message

Return to the
comp.compilers page.

Search the
comp.compilers archives again.