Questions tagged [regular-expression]
Code challenges that involve the use of regular expressions.
99 questions
11
votes
17
answers
916
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 ...
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 ...
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?
...
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 ...
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
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 ...
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
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%...
7
votes
4
answers
3k
views
Count regex matches
Your task
Given a simple regular expression, you have to count how many strings of length n have a match of length n with the ...
13
votes
1
answer
479
views
Duct Tape a Regex Decider
Your task is to create a program that determines whether a given string is a valid regular expression or not using code snippets sourced from sites on the StackExchange network.
For the purposes of ...
1
vote
0
answers
80
views
Print everything which a regular expression matches [duplicate]
Modern regular expressions (regexes) have many features (\d, {n,m}, \1, etc.), but to define ...
-4
votes
1
answer
885
views
Regex only base64 decoder [closed]
Write a regular expression substitution string which can base64 decode a string using only a regular expression engine built into the language. Eg:
...
17
votes
6
answers
1k
views
The Binary Fences
Input:
An integer n in the range 2 <= n <= 10
A list of positive integers
Output:
Convert the integers to their binary ...
20
votes
2
answers
2k
views
Complement of a Regex
For the purposes of this challenge, we define a postfix regex dialect with alphabet {1, 0} and the following operations:
1 and <...
6
votes
3
answers
382
views
Create a regex to match a given range of integers in a given radix
Task
Write a program/function that, given three integers n,a,b prints a regular expression which matches all of the base-n integers from ...
19
votes
2
answers
742
views
Regex: Match an egalitarian series
Introduction
I don't see many regex challenges on here, so I would like to offer up this deceptively simple one which can be done in a number of ways using a number of regex flavours. I hope it ...
6
votes
4
answers
589
views
The greedy regex (robbers)
This is the robbers' post. The cops' is here.
Your challenge is to take a cop's post and find an input that the regex matches but the program returns a falsey value.
Once you have cracked a cop's ...
7
votes
1
answer
2k
views
Regular expression parser
This task is a classic programming task: Implement a regular expression parser. That is, write a program or function which takes a string describing a regular expression and a candidate string, and ...
22
votes
41
answers
4k
views
Robbers: Crack the regex - Make a snake
This is the robber's thread. The cop's thread is here.
A snake matrix is a square matrix that follows this pattern:
3-by-3:
1 2 3
6 5 4
7 8 9
and 4-by-4:
...
2
votes
0
answers
156
views
Find letter-similar words in a word list [closed]
(I am not sure that this is the best place to put this question, but I will give it a shot. Forgive me if it is improper. This is just a fun project with which I am tinkering and I am looking for ...
15
votes
9
answers
2k
views
The codegolf object
Imagine this, we have an environment with a global scope containing just a single object, called codegolf. This object has a single child called ...
-4
votes
1
answer
546
views
A regex to satisfy the grammar police (there vs. their vs they're)
We've all been burned by the grammar police on the internet. What we need is a regex that can be used in place of "there", "their", and "they're". This would shift burden of grammar parsing from the ...
37
votes
3
answers
1k
views
HexaRegex: A Tribute to Martin Ender
Martin Ender recently hit 100K, and has come up with some pretty awesome languages. We're going to have a bit of fun with one of them, Hexagony (and a bit of regex for Retina)
As a brief overview, ...
2
votes
2
answers
752
views
Check if a pattern appears in a DNA sequence
In a project I am working on, I am checking to see if certain DNA sequences appear in certain genes in E. coli. I have written a program in Java that performs the below features. However, since I ...
10
votes
3
answers
528
views
RegEx-golf: match all contents in a string
Your task is to write a RegEx that matches everything inside strings.
A string is defined as everything surrounded by (but not including) two unescaped ".
A ...