All Questions
Tagged with python-3.xregex
73 questions
13votes
5answers
11kviews
Cleaning up date strings in Python
Working from a CSV of about 14.000 lines, I need to match dates in the CSV against some API. I'm reading the CSV using Pandas (for various other reasons). Most often, the date is just a year, i.e. an ...
13votes
2answers
5kviews
Average spam confidence
Exercise 7.2 from Python for Informatics: Write a program to prompt for a file name, and then read through the file and look for lines of the form: ...
10votes
3answers
3kviews
Imgur URL parser
Fairly new to Python, and I have been doing a few Edabit challenges, to better help with my problem-solving. I have just completed a some what semi-difficult challenge, and I was hoping for some feed ...
10votes
1answer
1kviews
Osherove TDD Kata 1: String Calculator
I implemented Roy Osherove's TDD Kata 1: String Calculator using Python 3.5.2 and the unittest module. The full description can be found at the link, it's a bit ...
9votes
2answers
12kviews
Find files by pattern and copy to target location
This is my solution to the Chapter 9 exercise in Automate the Boring Stuff: Selective Copy Write a program that walks through a folder tree and searches for files with a certain file extension (...
9votes
1answer
141views
Minimal regex engine
A few months back, I posted a state machine for review. Thanks to the feedback, I was able to greatly simplify the implementation. I am posting the revised version, together with the Regex class which ...
8votes
3answers
1kviews
Filter out ambiguous bases from a DNA sequence
I have this function: ...
8votes
2answers
10kviews
Regex Version of strip()
This problem is from Automate The Boring Stuff using Python - Chapter 7. Write a function that takes a string and does the same thing as the strip() string method. If no other arguments are passed ...
8votes
3answers
3kviews
Find website URLs that begin with http:// or https://
This is a problem from Automate the Boring Stuff from "Pattern Matching with Regular Expression". I am a beginner in Python and the purpose of this program is to match urls which start with ...
7votes
5answers
8kviews
Regex password strength test
I've been following a Python programming book and reached the Regex chapter where I encountered this challenge: Write a password strength checker that checks if a password is: At least 8 character ...
7votes
3answers
4kviews
Elegant way to replace substring in a regex with optional groups in Python?
Given a string taken from the following set: strings = [ "The sky is blue and I like it", "The tree is green and I love it", "A lemon is yellow" ] I ...
7votes
4answers
2kviews
Sort files in a given folders and provide as a list
I have two folders query and subject. The following function sorts alphabetically and provides the query and subject as a separate list. The file names are mixed of numbers and I found the sort ...
7votes
4answers
6kviews
Check if a file path matches any of the patterns in a blacklist
I'm processing a list of files, and want to check the filenames against a list of regex, like: ...
7votes
1answer
355views
Wrapper to enhance a program to translate from LTL formulae to Büchi automata
The following is a script that is supposed to act as a wrapper for ltl2ba, a program which transforms LTL formulas into Buchi Automatons encoded in the Promela language. The wrapper adds a limited set ...
7votes
1answer
425views
Stop cheating on home exams using python
Background I am teaching a course at university level, and have lately been working on creating a home exam for my students. However, the institute has given clear instructions that collaboration is ...