Linked Questions

0 votes
4 answers
205 views

I'm trying to find a word in a simple string no matter how it's written. For example: 'Lorem ipsum dolor sit amet lorem.' Let's say I search for 'lorem' written in lowercase and I'd like to replace ...
Ovidiu G's user avatar
  • 1,273
0 votes
1 answer
108 views

I use the search functionre.finditer() and get span as 1 tuple I'm trying a function that can handle any input import re text = "Thanks for the help, your Help is really good, it's really a big ...
Tmag's user avatar
  • 33
-1 votes
3 answers
82 views

sentence = 'this is a book.pdf' sentence.replace( 'pdf' or 'PDF' ,'csv' ) sentence.replace('pdf','csv',re.IGNORECASE) how can i replace the characters under the condition specified such as Pdf or ...
quadhd's user avatar
  • 81
0 votes
0 answers
55 views

I want my code to find and replace a word, but I don't want it to modify my text I would like my code to do something like that : text = 'Hello my pseudo is LittlePig and I am Happy' word = '...
Canapy's user avatar
  • 243
0 votes
0 answers
18 views

I have a variable in which I need to replace it with a word match. Currently this is my logic string = "This is a test" x = string.replace("Test", "") How can I make sure here cap T can match the ...
topgun's user avatar
  • 2,593
118 votes
13 answers
117k views

I'd like my dictionary to be case insensitive: text = "practice changing the color" words = {'color': 'colour', 'practice': 'practise'} def replace(words,text): keys = ...
Kim's user avatar
  • 3,554
0 votes
3 answers
3k views

I'm new to python and I'm trying to make a function which is able to detect if a string has the words "I", "I'm", "My", "Was", "Our", "me" replace it with "You", "You're", "Your", "Were", "Your" and "...
user2278906's user avatar
2 votes
3 answers
5k views

I am able to replace a word in a string content using the following solution in a case insensitive method http://code.activestate.com/recipes/552726/ import re class str_cir(str): ''' A ...
Rakesh's user avatar
  • 82.9k
2 votes
1 answer
4k views

I want to replace all occurrences of a set of strings in a text line. I came up with this approach, but I am sure there is a better way of doing this: myDict = {} test = re.compile(re.escape('pig'), ...
Amro Younes's user avatar
  • 1,311
0 votes
6 answers
1k views

My code so far is: def ChangeString(): print (userString.replace( userString =str(input("Please enter a string ")) ChangeString() In a string, I need to replace all instances of the first ...
The White Wolf's user avatar
2 votes
1 answer
1k views

I know this question has already been answered before here Case insensitive replace but mine is a little different. What I want is to search for certain keywords in a text and replace by surrounding ...
The Wanderer's user avatar
  • 3,281
0 votes
0 answers
1k views

Is there a way to get a case insensitive regex replace to work on a Pandas dataframe? I would prefer to keep the work vectorised instead of having to resort to creating a loop at the string level to ...
leerssej's user avatar
  • 15.1k
0 votes
1 answer
891 views

Is this code correct in python? def foo(flag): if flag: def bar(): # Somthing else: def bar(): # Somthing else bar() foo(True) foo(False) if not ...
ArmanHunanyan's user avatar
0 votes
2 answers
418 views

related question: Case insensitive replace What's the best way to do a case insensitive replace WITHOUT HURTING THE CACHE in the re module? I'm monitoring carefully the cache to make sure my favorite ...
Tal Weiss's user avatar
  • 9,059
0 votes
3 answers
629 views

I want to recognize if the words from a list are in an input string, and if so remove that word. I have tried: words = ["youtube","search youtube","play music"] Inp = &...
Angelyous Naguib's user avatar

15 30 50 per page