Skip to content

Tag: regex

Replace a list of elements with regex

I have a text full of adverbes and it’s replacements like this : And i want the adverbes to replaced in my text: Example : but am runing out of solutions, my code so far: I couldn’t find a way to replace each adverbes with the appropriate replacement. the list_adverbes_replacement.txt is the text …

Python RegEx check string

im trying to set correct version on output. I have this possible strings: 0.0.4.1 # 1. 7.51.4.1 # 2. 0.1.4.1 # 3. and i need to check, if the “0.” is on the start (to set output without 0. or 0.0.) Output 1. will have just “4.1”, 2. gonna stay the same and 3. will be 1.4.1 Im trying to

Wrong result with regular expressions

Any idea why the regular expression below cuts the ‘fl’ part of the sentence ? This is the result I get : Answer You’re replacing all non-alphabetical characters with whitespace. In your code, the ‘fl’ is actually fl – a single unicode (non-AZ) character, so it is being remo…

How to match IP addresses in a comma-separated string

Code show as below, but there is a problem: “255.255.255.256” will be processed into “255.255.255.25” If I pass the 255.255.255.255,255.255.255.256,260.255.255.255 string I expect [“255.255.255.255”] as the results. Answer You want to implement comma boundaries, (?<![^,]…