I need to get substrings from all text before ánd after two possible words. These words are “at” and “by”.
So when I have the following string:
“Hello this is a text by Piet”
NewVariable1: “Hello this is a text”
NewVariable2: “Piet”
But “by” is sometimes “at”. For this, I can build an if statement of course. But since I already have I few if statements in this bot I hope I can fix this with a regex for example. Does anybody know how to solve this problem? Would really appreciate it!
I think I tried these a already. Problem is that I cannot assign this array to a string so I have to indicate the first part first on this variable, and then do it again with the last variable, right?