You can use the re.split function with the re.IGNORECASE flag (or re.I for short):

>>> import re
>>> test = "hI MY NAME iS FoO bar"
>>> re.split("foo", test, flags=re.IGNORECASE)
['hI MY NAME iS ', ' bar']
>>>
Answer from user2555451 on Stack Overflow
🌐
Finxter
blog.finxter.com › home › learn python blog › python split string case insensitive
Python Split String Case Insensitive - Be on the Right Side of Change
November 22, 2022 - ✨Summary: Use the re.split function of the regex module to split the string using the given delimiter and set the regex flag re.IGNORECASE to ensure a case-insensitive split. Minimal Example Problem Formulation 📜Problem: Given a string containing a mixed blend of uppercase and lowercase ...
Discussions

Python regex split case insensitive in 2.6 - Stack Overflow
I have the following code that works in Python 2.7: entry_regex = '(' + search_string + ')' entry_split = re.split(entry_regex, row, 1, re.IGNORECASE) I need to make it work in Python 2.6 as well ... More on stackoverflow.com
🌐 stackoverflow.com
January 25, 2012
Case insensitivity in Python strings - Stack Overflow
I know that you can use the ctypes library to perform case insensitive comparisons on strings, however I would like to perform case insensitive replacement too. Currently the only way I know to do ... More on stackoverflow.com
🌐 stackoverflow.com
Python 1 -Use ‘for’, ‘.split()’, and ‘if’ to print out words that start with ‘b’(case-sensitive). Input: 'You cannot end a sentence because because because is a conjunction.' Output: because because
Answer to Python 1 -Use ‘for’, ‘.split()’, and ‘if’ to print More on chegg.com
🌐 chegg.com
1
March 30, 2021
python - Case insensitive replace - Stack Overflow
What's the easiest way to do a case-insensitive string replacement in Python? More on stackoverflow.com
🌐 stackoverflow.com
🌐
GeeksforGeeks
geeksforgeeks.org › python-case-insensitive-string-replacement
Case insensitive string replacement in Python - GeeksforGeeks
April 5, 2025 - Explanation: re.sub(r"(?i)best", lambda m: "good", a) uses a case-insensitive regex ((?i) inline flag) to match the word "best" in any casing within the string a, and replaces each match using a lambda function that returns "good". This method splits the string into individual words using split().
🌐
TutorialsPoint
tutorialspoint.com › article › case-insensitive-string-replacement-using-python-program
Case-insensitive string replacement using Python Program
January 27, 2023 - import re input_string = "Hello TutorialsPOINT Python" substring = "tutorialspoint" replace_string = "Java" # use (?i) for case-insensitive matching result = re.sub('(?i)' + re.escape(substring), replace_string, input_string) print("Result:", result) ... input_string = "Hello TutorialsPOINT Python" substring = "tutorialspoint" replace_string = "Java" words = input_string.split() result_words = [] for word in words: if word.lower() == substring.lower(): result_words.append(replace_string) else: result_words.append(word) result = " ".join(result_words) print("Result:", result)
🌐
w3resource
w3resource.com › python-exercises › re › python-re-exercise-44.php
Python: Do a case insensitive string replacement - w3resource
Write a Python function to implement case-insensitive string replacement using regex flags. ... Previous: Write a Python program to split a string at uppercase letters.
Find elsewhere
🌐
Mimo
mimo.org › glossary › python › string-split-method
Learn Python's String Split Method, Simplify Text Processing
The split() method is case-sensitive. For case-insensitive splitting, preprocess the string to a consistent case.
🌐
Chegg
chegg.com › engineering › computer science › computer science questions and answers › python 1 -use ‘for’, ‘.split()’, and ‘if’ to print out words that start with ‘b’(case-sensitive). input: 'you cannot end a sentence because because because is a conjunction.' output: because because
Solved Python 1 -Use ‘for’, ‘.split()’, and ‘if’ to print | Chegg.com
March 30, 2021 - Python · 1 -Use ‘for’, ‘.split()’, and ‘if’ to print out words that start with ‘b’(case-sensitive). Input: 'You cannot end a sentence because because because is a conjunction.' Output: because · because · because · 2 - Enhance the previous question to include case-insensitive comparison and remove duplicates from the output.
🌐
Stack Overflow
stackoverflow.com › a › 20782245
Newest Questions - Stack Overflow
Stack Overflow | The World’s Largest Online Community for Developers
🌐
PYnative
pynative.com › home › python › regex › python regex split string using re.split()
Python Regex Split String using re.split() – PYnative
July 27, 2021 - For example, you want to split ... or a combination of both. Here you can use the re.IGNORECASE or re.I flag inside the re.split() method to perform case-insensitive splits....
🌐
ProgramCreek
programcreek.com › python › example › 96 › re.IGNORECASE
Python Examples of re.IGNORECASE
def regex(self, response, port): match = False if re.search(b'<title>502 Bad Gateway', response): return match for pattern in SIGNS: pattern = pattern.split(b'|') if re.search(pattern[-1], response, re.IGNORECASE): text = response.decode('utf-8', 'ignore') match = True proto = {"server": pattern[1].decode(), "port": port, "banner": text} self.out.append(proto) break if not match: proto = {"server": get_server(port), "port": port, "banner": response.decode('utf-8', 'ignore')} self.out.append(proto)
🌐
GeeksforGeeks
geeksforgeeks.org › case-insensitive-string-comparison-in-python
Case-insensitive string comparison in Python - GeeksforGeeks
April 22, 2025 - We are given a string and our task is to replace a specific word in it, ignoring the case of the letters. This means if we want to replace the word "best" with "good", then all variations like "BeSt", "BEST", or "Best" should also be replaced. For example, if the input is "gfg is BeSt", then the out ... Sometimes, while working with Python strings, we might have a problem in which we have list of strings and we wish to convert them into specified cases.
🌐
Real Python
realpython.com › lessons › replace-string-python-case-insensitive
Be Case-Insensitive (Video) – Real Python
01:21 Currently, you have global and multi line activated, and that’s why your multiline string works as a test string, but you haven’t selected insensitive so that you look for case-insensitive matches. So once you select it, you will see that the regular expression successfully now finds BLASTED in uppercase or Blast with a uppercase B at the beginning.
Published: August 22, 2023
🌐
Reddit
reddit.com › r/learnpython › check if case sensitive with python (with boolean)
r/learnpython on Reddit: Check if case sensitive with python (with boolean)
October 15, 2017 -

How do I count how many times a case sensitive word appears somewhere using a boolean.

So for example:

word = input("Search this word: ")

Then I want to check if case sensitive == True or False. If it's true, it will only find the exact same words.

Also, the word can't be a part of another word. So it may not find "Apple" in Applepie. But it can only find "Apple" if it's independent like this: Apple Pie

Top answer
1 of 2
2
Well, in general it's case sensitive by default. So you can do first check if the word is in a sentence, and it'll only match when it's case sensitive. Then you can convert both to lowercase letters only and check if the lower case version of the word is in the lower case version of the sentence. Since you want to do only one with a boolean check, try: case_sensitive = True if case_sensitive: #do casesensitive check else: #do lowercase check If you don't want it to be part of another word, i guess it's a bit harder. But you can convert the sentence to a list with .split() and then check if it's in that list, since that will be on a word by word basis. Edit: And also remove punctuation and such.
2 of 2
1
As an aside, you're using the terminology wrong, and in this case, I think it matters and will cause you further confusion along the line if you don't get it clear. I'm not being snarky. It could also be a language thing, as I don't know your native tongue or english dialect, and both of these things can mean we would say things differently. The phrase "Check if case sensitive" doesn't make sense. A word cannot be case sensitive. A program can be case sensitive, that is, it can be sensitive to differences in the upper/lower case letters in a string. A word can be, in Python parlance, lowercase, UPPERCASE, Titlecase or mIxEd case. We say identifiers are in CamelCaps if the first letter of each word in the name is capitalised. I think you are really asking how to control whether a string complarison is case-sensitive or not, and others have ably answered that question. I usually do this by lowercasing everything like this: if case_sensitive_mode and word.lower() in sometext.lower(): # do case insensitive stuff elif word in sometext: # do case sensitive stuff As you want to find distinct words, however, re (regex) is the correct approach. Hope that helps.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations — Python 3.14.7 ...
Split string by the occurrences of pattern. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list.
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-write-a-case-insensitive-python-regular-expression-without-re-compile
How to write a case insensitive Python regular expression without re.compile?
March 24, 2026 - You can combine multiple patterns with case insensitivity ? import re text = "I love PYTHON and Java programming" languages = re.findall(r"python|java", text, re.IGNORECASE) print(f"Found languages: {languages}")