Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีเขียน Python Regex ดึง anchor tags ทั้งหมดจากเว็บเพจ

ใช้ regex ดึง tags ทั้งหมดในสตริงที่กำหนด

ตัวอย่าง

import re
rex = re.compile(r'[\<\>]')
l = "this is text1 hi this is text2"
print(rex.findall(l))

ผลลัพธ์

['<', '>', '<', '>']