โดย dawthana » 23/01/2017 4:54 pm
Search and Replace (เสริช แอนด์ ริพเลซ)
ใน
python (ไพทอน) นอกจาก
Regular Expression(รีกูวล่า เอ็กซ์เพรสชั่น) ยังมี
Method (เมธอด) ที่สำคัญ และใช้งานบ่อยๆอีกตัวหนึ่งคือ sub (ซับ) ที่ใช้สำหรับการแทนที่ด้วยข้อความที่ต้องการโดยมีรูปแบบการใช้งาน ดังนี้
โค้ด: เลือกทั้งหมด
Syntax re.sub(pattern , real , string , max=0)
ตัวอย่างการค้นหาและแทนที่
- 49_2.png (24.25 KiB) Viewed 1234 times
- 49_3.png (29.88 KiB) Viewed 1234 times
ศึกษาข้อมูลมาจาก
https://www.youtube.com/watch?v=He5l3Yx8ues&t=42s
[b]Search and Replace (เสริช แอนด์ ริพเลซ)[/b]
ใน [url=https://www.mindphp.com/%E0%B8%84%E0%B8%B9%E0%B9%88%E0%B8%A1%E0%B8%B7%E0%B8%AD/73-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3/2417-python-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3.html?bb_limitstart=2740]python (ไพทอน)[/url] นอกจาก [url=https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%A5%E0%B8%99%E0%B9%8C/83-python/2923-python-regular-expressions.html]Regular Expression(รีกูวล่า เอ็กซ์เพรสชั่น)[/url] ยังมี [url=https://www.mindphp.com/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B8%AD%E0%B8%AD%E0%B8%99%E0%B9%84%E0%B8%A5%E0%B8%99%E0%B9%8C/%E0%B8%AA%E0%B8%AD%E0%B8%99-joomla-extension/17-content/%E0%B8%9A%E0%B8%97%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99-php5-oop/166-oop-%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-methods-%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A-class-php5-method-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3.html?hitcount=0&bb_limitstart=240]Method (เมธอด)[/url] ที่สำคัญ และใช้งานบ่อยๆอีกตัวหนึ่งคือ sub (ซับ) ที่ใช้สำหรับการแทนที่ด้วยข้อความที่ต้องการโดยมีรูปแบบการใช้งาน ดังนี้
[code]Syntax re.sub(pattern , real , string , max=0)[/code]
[b]ตัวอย่างการค้นหาและแทนที่[/b]
[attachment=2]49_2.png[/attachment]
[attachment=1]49_3.png[/attachment]
[attachment=0]49_4.png[/attachment]
ศึกษาข้อมูลมาจาก [url]https://www.youtube.com/watch?v=He5l3Yx8ues&t=42s[/url]