Movatterモバイル変換


[0]ホーム

URL:


Regular Expression Question

Paul Prescodpaulp at ActiveState.com
Tue Apr 3 20:00:25 EDT 2001


Wesley Witt wrote:>> This is probably a simple question, but I can't seem to find the answer> anywhere.>> I want a regular expression that will match ALL lines that do NOT contain> the string "skip".  I have some backup logs that I need to filter the noise> out of.Why use a regular expression?You can do something like this (untested):for line in fileinput.readlines():    if line.find("skip")==-1:        print lineFor me, regular expressions are a last resort because they are hard toread later and often slower than string methods.-- Take a recipe. Leave a recipe.  Python Cookbook!http://www.ActiveState.com/pythoncookbook


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp