0

I am using Pandas to process a text variable, and I am not sure how to correctly write the following regex expression

  • containing the word ball OR the word hello anywhere in the text
  • contatining at least a number anywhere in the text

so that

  • ball red is good 02 is TRUE
  • ball ball is FALSE
  • 2003 was a pretty damn hello is TRUE

Any ideas? Thanks!

ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
  • Hi Wiktor I am sorry but I disagree. My regex is more complicated than the one on the link you provide, because there is an OR clause as well. Can you please re - open? – ℕʘʘḆḽḘ Apr 30 '17 at 15:19
  • question edited – ℕʘʘḆḽḘ Apr 30 '17 at 15:27
  • 2
    Yup: https://regex101.com/r/jGUzGK/1 – Jan Apr 30 '17 at 16:27
  • 1
    @Wiktor: It has similarities but it is not a duplicate in my opinion. – Jan Apr 30 '17 at 16:27
  • @Jan, it is a code request, it is not a question. The regex you showed in the comment above is the same - two positive lookaheads. – Wiktor Stribiżew Apr 30 '17 at 16:34
  • are you serious? how can this be not a question? also, I see your point of avoiding duplicates but with the OR condition I dont see how your link answers that – ℕʘʘḆḽḘ Apr 30 '17 at 16:43
  • 1
    @WiktorStribiżew: Of course it is a code request. But I guess, if we start to be this picky, a great amount of questions are duplicates of others. – Jan Apr 30 '17 at 16:47
  • The point is that the question I closed with perfectly answers the question in its current form: it provides all necessary hints and technique to use. The rest is up to the user. – Wiktor Stribiżew Apr 30 '17 at 16:48

0 Answers0