Women in Technology

Hear us Roar



Article:
  An Introduction to Haskell, Part 1: Why Haskell
Subject:   regex
Date:   2007-05-26 01:45:03
From:   pipping
'^(NYC?|New York( City)?)$'


is better written as


'^N(YC?|ew York( City)?)$'


or even


'^(?=N)(NYC?|New York( City)?)$'

Full Threads Oldest First

Showing messages 1 through 1 of 1.

  • regex
    2007-05-26 02:04:01  pipping [View]

    that came out wrong. i meant to say 'the above regex could be written differently, possibly resulting in optimization - forced optimization in the latter case, which might even be bad if the optimization is already present. however, '^N(YC?|ew York( City)?)$' will in any case be at least as fast as the original regex, the only downside could be decreased readability'

    kind regards!