2021年3月7日星期日

Python Regex: Create list based on splitting by certain words or symbols

I want to use regex and findall to create a list of words that meets specific conditions.

I basically want the list to be split by key words such as " hello ", " whatup ", etc. (notice all have one space before and after).

I also want the list to split by certain special characters like \ or ; or ^ or & , (, ) etc.

I tried the following findall regex: [^\;^&][\shello\s]+[\swhatup\s] but it did not work.

What can I do? What is wrong with my regex?

https://stackoverflow.com/questions/66523482/python-regex-create-list-based-on-splitting-by-certain-words-or-symbols March 08, 2021 at 10:07AM

没有评论:

发表评论