Find the shortest regex that matches all radioactive elements and nothing else in the Periodic Table of Elements.

Radioactive Elements


Non-radioactive Elements

  • Scored by character count in the regex.
  • Use standard Perl regex (just no specialized functions).
  • Assume all lower case.
  • You only need to count the characters of the regex itself.

Note if you used a program to get you started and maybe post how well it did. I'll post my best attempt as an answer to get started/show an example.

  • \$\begingroup\$ Can you quote a regex standard, such as POSIX regular, POSIX extended, PCRE…? Otherwise "language agnostic" doesn't really mean much. \$\endgroup\$
    – Tobia
    Jan 8, 2014 at 21:55
  • \$\begingroup\$ Sorry, I have only had to use regex in java and javascript and don't really know all the differences. The goal is to create a regex that would work in most common languages without relying on language specific feature. \$\endgroup\$
    – qw3n
    Jan 8, 2014 at 22:02
  • \$\begingroup\$ There is an ongoing discussion as to whether we want regex golf on this site. Please contribute. \$\endgroup\$ Jan 8, 2014 at 23:48
  • \$\begingroup\$ @qw3n You could say “regular expression describing a regular language” to exclude all the language specific things. \$\endgroup\$
    – FUZxxl
    Mar 8, 2015 at 11:58

4 Answers 4


Char Count 61


One 3 characters better than accepted answer!

63-character solution found with Peter Norvig's Regex golf solver. 61-character improvement found by a personal rewrite of that program in Go.


Char count 64


Should note, used parts of qw3n solution to reduce down my solution. Also used Peter Taylor's suggestion to trim two characters.

  • \$\begingroup\$ I have a feeling this is pretty near if not an optimal solution. Wish I'd seen that f.r part. :) \$\endgroup\$
    – qw3n
    Jan 10, 2014 at 1:05
  • 1
    \$\begingroup\$ There's an easy 1-char saving by grouping everything anchored on ^, and another by changing ^(u|cu|...) into ^(c?u|...) \$\endgroup\$ Jan 10, 2014 at 9:46

Char count 59


Found via a mix of manually selecting good parts and running Peter Norvig's golfer on the remaining items.

Regex101 link

  • \$\begingroup\$ LOL accepted answer after over 2 years! Imagine that @drjimbob's answer was the previous accepted answer. 3 characters better than accepted answer! \$\endgroup\$ May 31, 2016 at 18:28
  • \$\begingroup\$ For pete's sake! I've had the best answer for more than a year, and then I make it even better, and then you come along and do even better and get accepted! \$\endgroup\$
    – EMBLEM
    Jun 1, 2016 at 1:30

Char count 69


Curium/Cerium are a pain to deal with


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.