Skip to content
Advertisement

Tag: replace

Put comma after a pattern in python regex

Just like the question says I am trying to add a comma at the end of a pattern or sub string. I found 3 solutions that should do the job, and look logical too. But they are not changing anything. I will show you all those codes. The goal is to find out if there is something that I am

Trying to filter out A-Z and special characters in python

This is what I’ve tried so far: It doesn’t work, can you explain why? Answer Should work. This code will check with is_alpha if the i character is an alphabetic letter (A-Z, case unsensitive) and if it returns false, will add it to the new_string variable. Later, it will check if the string contains the characters to remove. Check information

Python-docx: Find and replace all placeholder numbers in Word doc with random numbers

I’m having trouble finding and replacing all occurrences of several placeholders within paragraphs of a Word file. It’s for a gamebook, so I’m trying to sub random entry numbers for the placeholders used while drafting the book. All placeholders begin with “#” (e.g. #1-5, #22-1, etc.). Set numbers, like the first entry (which will always be “1”), don’t have the

UTF-8 decoding doesn’t decode special characters in python

Hi I have the following data (abstracted) that comes from an API. I’m using the following code to decode the data byte: The cleanhtml is a regex function that I’ve created to remove html tags from the returned data (It’s working correctly). Although, decode(utf-8) is not removing characters like u00e1. My expected output is: I’ve tried to use replace(“\u00e1”, “á”)

Advertisement