Skip to content

Tag: regex

Efficient regex with lists

I have a list of strings coming from os.listdir() that looks like the following: out of those entries, I wanna get the ones that match the “backup_YYYYMMDD” pattern. The regex for that, with named groups, would be I am trying to create a list that contains the date only from the above (aka the .gr…

Python Web Scraping Div

I’m trying to scrape the job list from a web site, but I do not have enough experience with scraping. I found that all jobs are in a div block like this : What I want to access is the job title, job description and job link (<a href=”..”). Unfortunately, I couldn’t understand the lo…

Find first word in string Python

I have to write a single function that should return the first word in the following strings: All have to return the first word and as you can see some start with a whitespace, have apostrophes or end with commas. I’ve used the following options: Both error at some of the strings, so who can help me??? …

Validate card numbers using regex python

I have some credit card numbers with me and want to validate them over the below rules. ► It must only consist of digits (0-9) ► It may have digits in groups of 4, separated by one hyphen “-” ► It must NOT have 4 or more consecutive repeated digits ► It may contain exactly digits without any space…