Skip to main content
added 53 characters in body
Source Link
Doorknob
  • 72.1k
  • 20
  • 146
  • 393

The input regex will always be valid (i.e., you do not have to handle input like ?abc or (foo or any invalid input). You may output the strings in any order you would like, but each string must appear only once (don't output any duplicates).

Input: ab*a|c[de]*, 3
Output: (empty string), c, cd, ce, aa, cde, ced, cdd, cee, aba

The input regex will always be valid (i.e., you do not have to handle input like ?abc or (foo or any invalid input). You may output the strings in any order you would like.

Input: ab*a|c[de]*, 3
Output: (empty string), c, cd, ce, aa, cde, ced, cdd, cee, aba

The input regex will always be valid (i.e., you do not have to handle input like ?abc or (foo or any invalid input). You may output the strings in any order you would like, but each string must appear only once (don't output any duplicates).

Input: ab*a|c[de]*, 3
Output: c, cd, ce, aa, cde, ced, cdd, cee, aba

added 10 characters in body
Source Link
Doorknob
  • 72.1k
  • 20
  • 146
  • 393

You must input a regex and a number n, and output every string composed of printable ASCII (ASCII codes 32 to 126 inclusive, to ~, no tabs or newlines) of length less than or equal to n that matches that regex. You may not use built-in regular expressions or regex matching functions in your code at all. Regular expressions will be limited to the following:

The input regex will always be valid (i.e., you do not have to handle input like ?abc or a{two}(foo or any invalid input). You may output the strings in any order you would like.

You must input a regex and a number n, and output every string composed of printable ASCII (ASCII codes 32 to 126 inclusive, to ~, no tabs or newlines) of length less than n that matches that regex. You may not use built-in regular expressions or regex matching functions in your code at all. Regular expressions will be limited to the following:

The input regex will always be valid (i.e., you do not have to handle input like ?abc or a{two} or any invalid input). You may output the strings in any order you would like.

You must input a regex and a number n, and output every string composed of printable ASCII (ASCII codes 32 to 126 inclusive, to ~, no tabs or newlines) of length less than or equal to n that matches that regex. You may not use built-in regular expressions or regex matching functions in your code at all. Regular expressions will be limited to the following:

The input regex will always be valid (i.e., you do not have to handle input like ?abc or (foo or any invalid input). You may output the strings in any order you would like.

Tweeted twitter.com/#!/StackCodeGolf/status/452492140728549377
deleted 65 characters in body
Source Link
Doorknob
  • 72.1k
  • 20
  • 146
  • 393
  • Literal characters (and escapes, which force a character to be literal, so \. is a literal ., \n is a literal n (equivalent to just n), and \w is equivalent to w. You do not need to support escape sequences.)
  • . - wildcard (any character)
  • Character classes, [abc] means "a or b or c" and [d-f] means anything from d to f (so, d or e or f). The only characters that have special meaning in a character class are [ and ] (which will always be escaped, so don't worry about those), \ (the escape character, of course), ^ at the beginning of the character class (which is a negation), and - (which is a range).
  • | - the OR operator, matchesalternation. foo|bar means either all previous tokens up to a (foo or the beginning of the regex, or all subsequent tokens until a )bar or end of regex., and a|z(ab|cd)e meansmatches either aabe or zcde.
  • * - match the previous token repeated zero or more times, greedy (it tries to repeat as many times as possible)
  • + - repeated one or more times, greedy
  • ? - zero or one times
  • Grouping with parentheses, to group tokens for |, *. +, or ?
  • Literal characters (and escapes, which force a character to be literal, so \. is a literal ., \n is a literal n (equivalent to just n), and \w is equivalent to w. You do not need to support escape sequences.)
  • . - wildcard (any character)
  • Character classes, [abc] means "a or b or c" and [d-f] means anything from d to f (so, d or e or f). The only characters that have special meaning in a character class are [ and ] (which will always be escaped, so don't worry about those), \ (the escape character, of course), ^ at the beginning of the character class (which is a negation), and - (which is a range).
  • | - the OR operator, matches either all previous tokens up to a ( or the beginning of the regex, or all subsequent tokens until a ) or end of regex. a|z means either a or z.
  • * - match the previous token repeated zero or more times, greedy (it tries to repeat as many times as possible)
  • + - repeated one or more times, greedy
  • ? - zero or one times
  • Grouping with parentheses, to group tokens for |, *. +, or ?
  • Literal characters (and escapes, which force a character to be literal, so \. is a literal ., \n is a literal n (equivalent to just n), and \w is equivalent to w. You do not need to support escape sequences.)
  • . - wildcard (any character)
  • Character classes, [abc] means "a or b or c" and [d-f] means anything from d to f (so, d or e or f). The only characters that have special meaning in a character class are [ and ] (which will always be escaped, so don't worry about those), \ (the escape character, of course), ^ at the beginning of the character class (which is a negation), and - (which is a range).
  • | - the OR operator, alternation. foo|bar means either foo or bar, and (ab|cd)e matches either abe or cde.
  • * - match the previous token repeated zero or more times, greedy (it tries to repeat as many times as possible)
  • + - repeated one or more times, greedy
  • ? - zero or one times
  • Grouping with parentheses, to group tokens for |, *. +, or ?
added 138 characters in body
Source Link
Doorknob
  • 72.1k
  • 20
  • 146
  • 393
Loading
Source Link
Doorknob
  • 72.1k
  • 20
  • 146
  • 393
Loading