Great video! If I have a complex string like below, what should I do to split it into individual words? txt = "Thanks for letting me in here. The -- are you guys seeing any strange order patterns as far as like double ordering or any kind of panic inventory rebuild? Anything -- I mean, I would imagine you'd probably see it in transportation and electronics, kind of perhaps equally in transportation and electronics of all the segments. But I'll just leave it at that. Anything on the ordering patterns that's unusual."
You should just need to do txt.split() or txt.split(“ “) this will give you a list with every word since all your words are separated by spaces. If you want the the punctuation removed you can do something like: [curstr.replace(“,”, “”).replace(“.”, “”).replace(“?”,””) for curstr in txt.split(“ “)] Or you can use some regex to remove the punctuation as well
Thanks man you help me a lot
Great video! If I have a complex string like below, what should I do to split it into individual words?
txt = "Thanks for letting me in here. The -- are you guys seeing any strange order patterns as far as like double ordering or any kind of panic inventory rebuild? Anything -- I mean, I would imagine you'd probably see it in transportation and electronics, kind of perhaps equally in transportation and electronics of all the segments. But I'll just leave it at that. Anything on the ordering patterns that's unusual."
You should just need to do txt.split() or txt.split(“ “) this will give you a list with every word since all your words are separated by spaces. If you want the the punctuation removed you can do something like:
[curstr.replace(“,”, “”).replace(“.”, “”).replace(“?”,””) for curstr in txt.split(“ “)]
Or you can use some regex to remove the punctuation as well
@@CaseDigital great, do you have videos about regex?
Not at the moment but I’ll put it on my list for videos!
@@CaseDigital woa. Thank you