RegularExpressionsarenoworsetoreadormaintainthananyotherunformattedcontent;indeedaregexisprobablyeasiertoreadthatthispiecehere-butunfortunatelytheyhaveabadreputationbecausesomeimplementationsdon'tallowformattingandpeopleingeneraldon'tknowthatyoucandoit.
<br/>
Here's a trivial example:
^(?:[^,]*+,){21}[^,]*+$
<br/>
Which isn't really that difficult to read or maintain when it looks like this:
(?x) # enables comments, so this whole block can be used in a regex.
^ # start of string
(?: # start non-capturing group
[^,]*+ # as many non-commas as possible, but none required
, # a comma
) # end non-capturing group
{21} # 21 of previous entity (i.e. the group)
[^,]*+ # as many non-commas as possible, but none required
$ # end of string
That's a bit of an over-the-top example (commenting `$` is akin to commenting `i++`) but clearly there should be no problem reading and understanding that, and if maintenance is required it should be fine too.