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.
`Data.replace(' - ','; ')` will replace all keywords separated by hyphens and a space on each side to keywords separated by semicolons and one space. Add that into your code to prior to the if statement and you should be good to go.

Code:

```
data = ['Keyword1 - Keyword2 - Keyword3','Keyword4 - Keyword5']

final = [item.replace(" - ", "; ") for item in data]

print(final)

```

Output:

```
['Keyword1; Keyword2; Keyword3', 'Keyword4; Keyword5']

```