Questions tagged [regular-expression]
Code challenges that involve the use of regular expressions.
99 questions
11
votes
17
answers
923
views
Identify Redundant Regex
A redundant regular expression (regex) is defined here as a regex which has some amount of characters which can be removed while not affecting its functionality -- i.e. it matches the exact same set ...
10
votes
1
answer
1k
views
14
votes
10
answers
1k
views
Enumerate all matches of a regex
related
For this challenge, we'll be using a simplified dialect of regular expressions, where:
A lowercase letter from a to z ...
1
vote
1
answer
268
views
What is the shortest regular expression (REGEX) you can create for file extensions for image formats? [duplicate]
What is the shortest regular expression (REGEX) you can create for file extensions for all of the following image file formats (photographs, paintings, sketches, and drawings)?
...
8
votes
5
answers
2k
views
What is the shortest regex for the month of January in a handful of the world's languages?
What is the shortest regular expression equivilant to the following?
...
7
votes
3
answers
416
views
Write a regex that would increment a 2-digit hexadecimal number
Your regex will receive a string of the form
!XX!
#<extra>
where X is any hexadecimal digit (0-9 and A-F capital letters ...
15
votes
3
answers
439
views
Is it a bigger regex?
You are given two regexes and your task is to determine if the strings matched by the first regex are a subset of the strings matched by the second regex.
For this we are going to use a limited ...
6
votes
2
answers
371
views
Generate Matching Regexes
Write a program that takes two lists of strings and generates a javascript regex that fully matches all the strings in the first list and matches none of the strings in the second list.
To be specific ...
14
votes
9
answers
2k
views
Convert Regex to Mask
From my CMC.
Given a regex and a non-empty printable ASCII text, return one bit per character in the text, indicating the positions of beginnings of non-overlapping matches, and also the positions of ...
5
votes
2
answers
836
views
Give the minimum Levenshtein distance to a string that matches the regex
Your task, at the moment that you choose to accept it, is to write a program that, when given a string and a PCRE-regex, calculates the minimum Levenshtein distance to another string that matches the ...
5
votes
2
answers
1k
views
Generate the shortest regex to match these but not those [closed]
Challenge
Given two lists of strings where each string is of length 50 and each list is also of length 50 generate the shortest regex you can that fully matches all the strings in the first list and ...
26
votes
7
answers
2k
views
Recognize most smaller primes with a regex
This time, you are working on a regex. Your regex is meant to approximately full-match the base-10 representations of primes \$0 \le p < 1000\$, while ignoring any non-numeric string or composite ...
9
votes
1
answer
241
views
Are We Fast And Furious? [closed]
There are currently nine feature length films in the core Fast & Furious/The Fast and the Furious media franchise, a series of films about bald men scowling and driving cars very fast. The names ...
11
votes
1
answer
292
views
Generating minimal regular expression character classes
Background
Character classes are a standard way to indicate a set of characters to match in regular expressions. For example, the class [ab] matches a or b, ...
11
votes
2
answers
2k
views
Distinguish English and Spanish with regular expressions
The task is to to compete for the shortest regex (in bytes) in your preferred programming language which can distinguish between English and Spanish with minimum 60%...