Code challenges that involve the use of regular expressions.

learn more… | top users | synonyms

16
votes
4answers
3k views

Meta regex golf

In the spirit of this xkcd Write a program that plays regex golf with arbitrary pairs of lists. The program should at least attempt to make the regex short, a program that just outputs ...
15
votes
4answers
987 views

Match strings whose length is a fourth power

Within the scope of this question, let us consider only strings which consist of the character x repeated arbitrary number of times. For example: <empty> x xx xxxxxxxxxxxxxxxx (Well, ...
8
votes
2answers
506 views

Compile Regexes

In this task you have to write a program that reads a regular expression and generates another program that outputs whether an input string is accepted by that regular expression. The output must be a ...
8
votes
4answers
530 views

Generate regular expressions for matching natural numbers between `m` and `n`

The type of regular expression is PCRE. Write a program that output a valid PCRE such that it matches all natural numbers between m and n and does not match anything else. No leading zeros are ...
54
votes
24answers
11k views

Shortest unmatchable regular expression

Your mission is to write the shortest valid regular expression that no string can match, empty string included. Submissions must have this form ("literal notation"): /pattern/optional-flags ...
6
votes
3answers
969 views

Self-matching regex

Write a non-trivial regex that matches itself. For example, #.*$ will match a comment outside of a string in python until the end-of-line, and also matches itself in perl regex syntax. Rules: The ...
4
votes
2answers
231 views

Regex for Finding Radioactive Elements

Find the shortest regex that matches all radioactive elements and nothing else in the Periodic Table of Elements. Radioactive Elements ...
9
votes
2answers
610 views

Regex in reverse - decompose regular expressions

The Problem I have a bunch of regular expressions that I need to use in some code, but I'm using a programming language that doesn't support regex! Luckily, I know that the test string will have a ...
3
votes
2answers
143 views

Reverse Regular expressions [closed]

The idea here is to write a little segment that will spit out regular expression patterns when given a string that matches them. As you might have guessed, this will be a popularity contest, and I'll ...
3
votes
2answers
266 views

Negative Regexp

Write the shortest function that takes one string, and returns a regular expression that matches anything EXCEPT the input string, in parenthesis. Escape necessary characters like Perl quotemeta. ...