ใช้ re.split(delimiter_regex, string)
ตัวอย่าง
a = 'Beautiful, is; better*than\nugly'
import re
print(re.split('; |, |\*|\n', a))
ผลลัพธ์
['Beautiful', 'is', 'better', 'than', 'ugly']
Regex pattern ใช้ | คั่น delimiters ต่างๆ
ใช้ re.split(delimiter_regex, string)
a = 'Beautiful, is; better*than\nugly'
import re
print(re.split('; |, |\*|\n', a))
['Beautiful', 'is', 'better', 'than', 'ugly']
Regex pattern ใช้ | คั่น delimiters ต่างๆ