Question: I want to split either comma, semicolon or hyphen (with preceding space) separated words.  

The reason for this is the inconsistent structure of a website I am scraping with [Scrapy](https://docs.scrapy.org/en/latest/).  

So far, I am able to split either comma or semicolon separated words with follwing code:

```py
for i in response.xpath('//meta[@name="keywords"]/@content').extract():
        if ',' or ';' in i:
            for k in i.split(',') or i.split(';'):
                keywords.append([k.strip()])
        else:
            keywords.append([i.strip()])

```

That works if the words are separated like: 

* **keyword1, keyword2, keyword3**
* **keyword1; keyword2; keyword3**

But sometimes the keywords are also stored as follows:

**keyword1 - keyword2 - keyword3**

I don't know how to split them properly, because the spaces in between the hyphens are giving me headache :). Help is very much appreciated!

Answer: 
It appears to be a problem with my code I posted in my original question. Thus, there isn't really a problem with the spaces in between hyphens and I can simply solve the issue by using the elif statement as follows:

```
for i in response.xpath('//meta[@name="keywords"]/@content').extract():
        if ',' in i:
            for k in i.split(','):
                keywords.append([k.strip()])
        elif ';' in i:
            for k in i.split(';'):
                keywords.append([k.strip()])
        elif ' – ' in i:
            for k in i.split(' – '):
                keywords.append([k.strip()])
        else:
            keywords.append([i.strip()])

```

Anyway, thank you all for your suggestions on solving this issue.
You can simply replace all special characters giving you headache with wight space then split it.

```
import re
string = "keyword - keyword; keyword,keyword-keyword"
re.sub("[-;,]", " ", string).split()

```

Output:

```py
['keyword', 'keyword', 'keyword', 'keyword', 'keyword']

```