antonlab
antonlab

Reputation: 343

Python - How to combine multiple re.sub functions into a single function?

for i in (f):
    r = re.sub('.*\.f', '.wiki [href*=""], .f', i)
    s = re.sub('width', 'min-width', i)
    t = re.sub('height:40px;', '', i)

    outp.append(r)
    outp.append(s)
    outp.append(t)

As you can see, I have 3 lines of regex that work individually but it doesn't work like how I'd want to because they are appended 3 times so I need to combine them and append it once.

Upvotes: 0

Views: 495

Answers (1)

Cantfindname
Cantfindname

Reputation: 2148

Something like this?

for i in (f):
    r = re.sub('.*\.f', '.wiki [href*=""], .f', i)
    s = re.sub('width', 'min-width', r)
    t = re.sub('height:40px;', '', s)

    outp.append(t)

Upvotes: 3

Related Questions