They’re a freakin’ nightmare. They just are.
But, based on the premise that Sisyphus was a quitter, I took another stab at it, this time writing a real (PEG-) parser instead of trying to futz with extended regular expressions.
The results, so far, aren’t too bad.
The gem is called lc_callnumber, but more importantly, I’ve put together a little heroku app to let you play with it, and then correct any incorrect parses (or tell me that it worked correctly) to build up a test suite.
[Code for the app itself is on github; pull requests for both the app and the gem joyously received]