Answer the question
In order to leave comments, you need to log in
How to remove part of a string using a regular expression?
There is a spider that finds a lot of lines of this kind:
Code:
____code_____ I want to remove "Code:" from these lines, i.e. so that only one ___ code is transmitted ___
I tried to do this:
def parse_code(x):
s = re.sub('(^[\W]{3}\:{1}\s{1})', '', x)
if not s:
return None
return s
def parse_code(x):
s = str(x).translate(None, 'Код: ')
if not s:
return None
return s
class TestItem(Item):
code = Field(input_processor=MapCompose(parse_code))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question