0
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.

2
  • 2
    You also can use a single line: re.sub('height:40px;', '', re.sub('width', 'min-width', re.sub('.*\.f', '.wiki [href*=""], .f', i))). Just replace each i with another re.sub(). The inner-most re.sub() function will be evaluated first. This is the same as the answer given by Cantfindname. Commented Oct 22, 2015 at 9:30
  • "they are appended 3 times" - because that's exactly what you ask it to do. Have you considered reading the code before asking a question? Commented Oct 22, 2015 at 9:32

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.