Skip to content

Tag: regex

Python, Regex, extract grouped emails within curly brackets

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…

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_…

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