I’m trying to extract multiple Emails from string. I’m using this regex: It works fine, but sometimes in text Email names with the same domain are grouped in curly brackets: So my question is how properly to parse it and extract as separate emails: annie@gmail.com, bonnie@gmail.com? I’ve tri…
Tag: regex
How to replace and insert a new substring in python?
This is a working code and mabybe not very effcient code to replace a substring with another substring previously modified Input string : Output string: It has to replace substring like ‘part1’ ‘part2 an so on , with ‘PT’ and copy it between title and year substring Code: but whe…
Python Regex DataFrame match
I have a DataFrame and I would like to perform a sorting if the match between my regex and the name of one of the lines of this DataFrame matches. Is there an option in the “re” library to help me? I try with this piece of code but without success Thank you in advance for your answers Answer I
Regex pattern for filename with date
I have files with name “data_2021_03_v1.0.zip” in server. When I tried using “data.*(ZIP|zip)” regex.It is loading all files starting with data string. I want files containing only data(exactmatch-no extra words along with it) in filename. Ex: It is loading files with name “data_…
Ignore text from dot to a specific character with regex python
I have a text like this: i want a regex code that is able to delete the text inside the quotes and the text before it till the dot. so the output be like that : the code am stuck into : what the code actually does is delete a more than expected here’s an example : the output i
Python search for character pattern and if exists then indent
I have a pattern of text that I would like to find and push to a new line. The pattern is ), followed by a space and a character. Like this – where it would become I’m pretty close to a solution, but stuck on what approach to use. Currently, I’m using re.sub but I believe that removes the fi…
Find value from string using the characters from list Using Python
I have been working on an Excel sheet using python, where i have to extract only the specific value from the column, using an list with set of charaters. Need to check every character from the column check with the list, If it matches need to return the matched value into the dataframe which can be used for f…
regex lookahead AND look behind
I have the following 2 variations of scraped data: and I’d like to make one regular expression that gets the percentage as a float, so in the first instance 3.0 and in the second 3.57 I’ve tried this so far: Which works for the variation 2 but not variaton 1. Answer You may try this code to grab y…
Regex make a group optional
I have the below messages to parse The regex which I have so far is I am able to match almost everything I except the line Dispatch Queue size: 2 Looks like the last group in my regex should be optional. I tried using ? but I am unable to figure out the proper syntax. Can someone please suggest the
Not finding a good regex pattern to substitute the strings in a correct order(python)
I have a list of column names that are in string format like below: Now I want to add df[] with ” ‘ ” to each column name using regex and I did it which does that when the list has (wallet-phone) this kind of string it gives an output like this df[(‘wallet’]-df[‘phone’…