Hi, I am wondering if its possible to put a negation inside a .split.
For example something like, x.split(not y)
I’ve tried it in the past and never worked but I am wondering if there is a way to do it. Ideally I would think this would split everything that is not y.
what’s .split? str.split? if it accepts an argument, what does it promise to do with that argument, and would that let you leverage that the way you describe? so you’d need to read its documentation…right?
If you are indeed talking about text, then you can use regular expressions to describe various text patterns:
you can also write your own splitter function with that behaviour.
you definitely can’t use it that way though, since the result of the not operator is a boolean, and True/False is not enough information to convey “anything but y”, you would probably instead want to pass in a function which accepts a character and returns true/false to indicate whether it is a match