-2

I need to take the links src, css, href, a html page and save them to a text file.

I need to do with regular expressions (regex). Thanks!

Mangux
  • 413
  • 3
  • 14

1 Answers1

0
import re

p = re.compile(ur'.*(src|css|href|a html).*')

test_str1 = '<a html>'
test_str2 = 'String without any tags'

if re.match(p, test_str1) is not None:
    print test_str1

if re.match(p, test_str2) is not None:
    print test_str2
>> <a html>

Here is a solution for python 2.7, I assume that you understand the regex part but if not here is a good tutorial site that you can use to test your regex.

Daniel Lee
  • 7,189
  • 2
  • 26
  • 44