replace

How do I replace characters in a list of strings with a different character?

How do I replace characters in a list of strings with a different character? Question: I am making a platformer with enemies and want to have enemies randomly placed on the map. My map contains lists of strings that specify the map tiles. Basically I just want to randomly put the letter ‘E’ on a …

Total answers: 1

Replacing Overlapping Regex Patterns in Python

Replacing Overlapping Regex Patterns in Python Question: I am dealing with trying to make a .ttl file I was handed digestible. One of the issues is that the rdfs:seeAlso values are not sanitized and it breaks down downstream programs. What I mean by this is that there are links of the form: rdfs:seeAlso prefix:value_(discipline) In …

Total answers: 3

Randomly changing letters in list of string based on probability

Randomly changing letters in list of string based on probability Question: Given the following data = [‘AAACGGGATTn’,’CTGTGTCAGTn’,’AATCTCTACTn’] For every letter in a string not including (n), if its probability is greater than 5 (i.e. there is a 50% chance for a change), I’d like to replace the letter with a randomly selected letter from options …

Total answers: 2

Remove words from list but keep the ones only made up from the list

Remove words from list but keep the ones only made up from the list Question: I have one dataframe containing strings and one list of words that I want to remove from the dataframe. However, I would like to also keep the strings from the df which are entirely made up of words from the …

Total answers: 3

How to replace all string patterns except for one?

How to replace all string patterns except for one? Question: I have a string and a pattern that I’m trying to replace: my_string = "this is my string, it has [012] numbers and [1123] other things, like [2] cookies" # pattern = all numbers between the brackets, and the brackets I want to replace all …

Total answers: 2

Change slides' field in presentation with pyhton

Change slides' field in presentation with pyhton Question: I have an excel file and I would like to use these items to replace my slides, I added ABC code to replace my presentation but I can reach the title but cannot reach to paragraph. Could you please explain how I can reach to paragraph and …

Total answers: 1

How to capture all substrings that match this regex pattern, which is based on a repeat range of 2 or more consecutive times?

How to capture all substrings that match this regex pattern, which is based on a repeat range of 2 or more consecutive times? Question: import re input_text = "((PERS)Marcos) ssdsdsd sdsdsdsd sdsdsd le ((VERB)empujé) hasta ((VERB)dejarle) en ese lugar. A ((PERS)Marcos) le ((VERB)dijeron) y luego le ((VERB)ayudo)" input_text = re.sub(r"((PERS)((?:ws*)+))s*((?!el)w+s+){2,}(le)", lambda m: print(f"{m[2]}"), input_text, flags …

Total answers: 1

Dataframe : replace value and values around based on condition

Dataframe : replace value and values around based on condition Question: I would like to create a filter to replace values in a dataframe column based on a condition and also the values around it. For exemple I would like to filter values and replace then with NaN if they are superior to 45 but …

Total answers: 2

Replacing a substring (tag) in a given string in python based on dict

Replacing a substring (tag) in a given string in python based on dict Question: I am trying to replace inside a json text(which i transformed to string via json.dumps) one tag like {Prio}. This tag i append to the end of the string. The strange thing is the tag {name} is replaced but the tag …

Total answers: 1