Hacker News new | ask | show | jobs
by jdwhit2 4999 days ago
This examples looks like it covers a large number of cases:

      extractValues('John Doe <john@example.com> (http://example.com)', '{name} <{email}> ({url})')
    >> {'name': 'John Doe', 'email': 'john@example.com', 'url': 'http://example.com' }
What kinds of problems would you run into vs using regex? My thoughts were that you lose some control of your matches.
1 comments

You lose the ability to write them quickly, which considering I mainly use them for code editing or one-off uses, is quite important. The thing about regular expressions is they aren't suited to general programming in their normal form (since they are hard to read, and slow), and the quoted example is better described as a general parser, and could be implemented much better directly then abstracting through regular expressions.