0

Anyone help me with multiple delimeters for split function? For instance, given a string "#1(X,Y)", I want to use delimiters such as (, ',', ) to get a set like ('#1', 'X', 'Y')

Thanks

youngtackpark
  • 1,475
  • 3
  • 12
  • 14
  • 3
    Does this answer your question? [Split string with multiple delimiters in Python](https://stackoverflow.com/questions/4998629/split-string-with-multiple-delimiters-in-python) – ThePyGuy May 07 '21 at 08:04

1 Answers1

0

You separate delimiters with a "|".

For example:

import re
test_string = "'X, Y; Z*W'"
re.split('; |, |\*|\n',test_string)
['X', 'Y', 'Z', 'W']
Mattjo
  • 157
  • 1
  • 11