Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Hi, I'm facing a strange situation. These FIND and REPLACE do not work. That is, finding works, but replacing does not work.
- In these 3 situations, I have to replace an annuit regex with (empty space). See that '' there
- If at re.findall I put any simple regex, for example an html tag <div> then the replacement is done perfectly.
- But if it is a different kind of regex, such as the ones below, the replacement is no longer done. I mean nothing happens ...
- if len(re.findall('(?!<p>).+?(?<!</p>)$', page_text)) != 0:
- page_text = re.sub('(?!<p>).+?(?<!</p>)$', '', page_text)
- counter_img += 1
- OR
- if len(re.findall('^\s+</p>', page_text)) != 0:
- page_text = re.compile(r'', page_text)
- counter_img += 1
- OR
- if len(re.findall('\n\s*', page_text)) != 0:
- page_text = re.sub('\n\s*', '', page_text)
- counter_img += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement