how to write this re?
Mindy
csshi99 at yahoo.com
Thu Nov 7 00:14:10 EST 2002
More information about the Python-list mailing list
Thu Nov 7 00:14:10 EST 2002
- Previous message (by thread): how to write this re?
- Next message (by thread): tcl/python interaction problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hey, I want to find strings which includes "string1" but not includes "string2" in a bunch of strings called "lines", how can I write this regular expression in Python? For "axystring1bdestring2lkj", "aaastring1bbbccc","aaabbbstring2poi","aaabbbcccddd" I only want to get the string "aaastring1bbbccc" but my program got two strings: "axystring1bdestring2lkj" and "aaastring1bbbccc". So in my regular expression, (?!string2) didn't work at all. I know I shouldn't write this,but I really don't know how to express "not including string2". My regular expression is like: r=re.search(r'(.*)string1(.*)(?!string2)(.*)',lines) if r: string1 = r.string Thanks for any hints! ===== Cheers -Mindy __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2
- Previous message (by thread): how to write this re?
- Next message (by thread): tcl/python interaction problem
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list