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

วิธีหา matches ทั้งหมดของ Regular Expression ใน Python

ใช้ re.findall หรือ re.finditer หา matches ทั้งหมดของ regular expression

  • re.findall(pattern, string) คืน list ของสตริงที่จับคู่
  • re.finditer(pattern, string) คืน iterator ของ MatchObject objects