catastrophic regexp, help!
TheSaint
fc14301589 at icqmail.com
Wed Jun 11 11:04:29 EDT 2008
On 12:20, mercoledì 11 giugno 2008 cirfu wrote:
> patzln = re.compile("(\w* *)* zlatan ibrahimovic (\w* *)*")
I think that I shouldn't put anything around the phrase you want to find.
patzln = re.compile(r'.*(zlatan ibrahimovic){1,1}.*')
this should do it for you. Unless searching into a special position.
In the other hand, I'd like to understand how I can substitute a variable
inside a pattern.
if I do:
import os, re
EOL= os.linesep
re_EOL= re.compile(r'[?P<EOL>\s+2\t]'))
for line in open('myfile','r').readlines():
print re_EOL.sub('',line)
Will it remove tabs, spaces and end-of-line ?
It's doing but no EOL :(
--
Mailsweeper Home : http://it.geocities.com/call_me_not_now/index.html
More information about the Python-list
mailing list