Regular expression negative look-ahead

Neil Cerutti neilc at norwich.edu
Tue Jul 2 14:15:10 CEST 2013


On 2013-07-01, Jason Friedman <jsf80238 at gmail.com> wrote:
>
> I have table names in this form:
> MY_TABLE
> MY_TABLE_CTL
> MY_TABLE_DEL
> MY_TABLE_RUN
> YOUR_TABLE
> YOUR_TABLE_CTL
> YOUR_TABLE_DEL
> YOUR_TABLE_RUN
>
> I am trying to create a regular expression that will return true for only
> these tables:
> MY_TABLE
> YOUR_TABLE

Use the "is not a word" character class on either end.

r"\WMY_TABLE\W"
r"\WYOUR_TABLE\W"

-- 
Neil Cerutti



More information about the Python-list mailing list