Case Insensitive Python string split() method

Viewed 7303

I have 2 strings

a = "abc feat. def"
b = "abc Feat. def"

I want to retrieve the string before the word feat. or Feat.

This is what I'm doing,

a.split("feat.", 1)[0].rstrip()

This returns abc. But how can I perform a case insensitive search using split delimiter?

This is what I've tried so far

b.split("feat." or "Feat.", 1)[0].rstrip()

Output - abc Feat. def

b.split("feat." and "Feat.", 1)[0].rstrip()

Output - abc

a.split("feat." and "Feat.", 1)[0].rstrip()

Output - abc feat. def.

a.split("feat." or "Feat.", 1)[0].rstrip()

Output - abc

Why is this difference with and and or in both the cases?

3 Answers
Related