import re html = ''' <Div> <p> Miracle Longyin shaking variant </ p> </ div> <Div> <p> international situation sinks diving trips </ p> </ div> '' ' # Greedy matching pattern = the re.compile ( ' <div> <P>. * </ P> </ div> ' , re.S) r_list = pattern.findall(html) print(r_list) # Non-greedy matching pattern = re.compile ( ' <div> <the p-> (. *?) </ The p-> </ div> ' , re.S) r_list = pattern.findall(html) print(r_list)
Matches any single character regular expression:
Import Re # method of pattern = the re.compile ( ' . ' , re.S) # Method Two pattern = the re.compile ( ' [\ S \ S] ' )
Matches any number of characters in regular expressions:
Import Re # method of pattern = the re.compile ( ' . *? ' , re.S) # Method Two pattern = the re.compile ( ' [\ S \ S] *? ' )