Skip to main content
Post Made Community Wiki by alfa64
Source Link
WReach
  • 131
  • 3

I think the ubiquity of regex is due to the ubiquity of strings. The string is the simplest data structure, the first one that most of us learn. Since all of our code is written in symbolic form, it is natural for a programmer to consider modelling something in symbolic form. But if our programming language offers any resistance when we try to extend its syntax for our clever new symbolic forms, they all end up between quotes. The relational data model has SQL. The XML data model has XQuery. But what about the humble string data model? Regex!

Just yesterday, I was looking over the API for a shiny new Javascript framework that supports HTML5 game development. It has a declarative mechanism for describing the main subsystems that your game would need. How does one specify those features? JSON? Fluent dot notation? An array? Nope -- a string containing a comma- and whitespace-separated list of feature names. I wonder how it parses that list... ?