The most difficult part of regex isn't defining the problem. I'd say that one's easy. The hardest part is figuring out your regex months or years after you've written it!
Sadly, the only one that does is perl6.
For example, using C, file-local, pre-processor:
#define MATCH_NAME_RE "[a-zA-Z]+"
#define MATCH_SPACES_RE "\s+"
#define CAPTURE_NUMBER_RE "(\d+\)"
And then:
re = QRegex( MATCH_NAME_RE MATCH_SPACES_RE CAPTURE_NUMBER_RE );
It both documents what each part does, makes it easier to debug and change them later on and makes them grokable. It only breaks down when you're doing very complex matching, but most of the time RE can be broken into smaller pieces. a = re.compile(r"""\d + # the integral part
\. # the decimal point
\d * # some fractional digits""", re.X) OPERATOR = /// ^ (
?: [-=]> # function
| [-+*/%<>&|^!?=]= # compound assign / compare
| >>>=? # zero-fill right shift
| ([-+:])\1 # doubles
| ([&|<>])\2=? # logic / shift
| \?\. # soak access
| \.{2,3} # range or splat
) ///
When turned into Javascript it becomes: var OPERATOR;
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;