Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28552

Re: regex tidy

Path csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: regex tidy
Date Fri, 23 May 2014 15:05:41 -0500
Organization A noiseless patient Spider
Lines 24
Message-ID <llo9mp$ej7$1@dont-email.me> (permalink)
References <375vn9th0bc1faa04eg136be53hbvfjq4v@4ax.com> <o9GdnRy5BZPqP-LOnZ2dnUVZ7vGdnZ2d@giganews.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Fri, 23 May 2014 20:05:46 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="8b6ddcc38ecbed2f71b30fabadb8aa0b"; logging-data="14951"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZpNtqczKyORuZMOxfVOH8ZkMpKb7YJa0="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101 Thunderbird/30.0
In-Reply-To <o9GdnRy5BZPqP-LOnZ2dnUVZ7vGdnZ2d@giganews.com>
Cancel-Lock sha1:1nwl4vqybqV/JmMQSId2sjCZ/jI=
Xref csiph.com comp.lang.java.programmer:28552

Show key headers only | View raw


On 5/23/2014 2:33 PM, Leif Roar Moldskred wrote:
> Roedy Green <see_website@mindprod.com.invalid> wrote:
>>
>> What would a Java regex tidier do?
>>
>
> Evil.
>
> Regular expressions should be written to as closely as
> possible mirror a mental or conceptual model of the
> inputs it will match, and not to be as short or compact
> as possible.
>
> For instance, to match dates on the pattern "YY-MM-dd"
> your regular expression should be "\\d{2}-\\d{2}-\\d{2}"
> and not "((^|-)\\d{2}){3}"

Those two regexes aren't actually equivalent. The latter matches 
-00-00-00, for example. I assume you meant "\\d{2}(?:-\\d{2}){2}"?


-- 
Beware of bugs in the above code; I have only proved it correct, not 
tried it. -- Donald E. Knuth

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-23 11:39 -0700
  Re: regex tidy leif.roar@invalid.com (Leif Roar Moldskred) - 2014-05-23 14:33 -0500
    Re: regex tidy Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-05-23 15:05 -0500
  Re: regex tidy Robert Klemme <shortcutter@googlemail.com> - 2014-05-24 14:55 +0200
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:09 -0700
      Re: regex tidy Robert Klemme <shortcutter@googlemail.com> - 2014-05-25 18:49 +0200
        Re: regex tidy leif.roar@invalid.com (Leif Roar Moldskred) - 2014-05-25 12:28 -0500
          Re: regex tidy Robert Klemme <shortcutter@googlemail.com> - 2014-05-25 19:55 +0200
          Re: regex tidy "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-05-26 12:12 +0100
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:10 -0700
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:13 -0700
    Re: regex tidy Roedy Green <see_website@mindprod.com.invalid> - 2014-05-25 09:21 -0700
      Re: regex tidy Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> - 2014-05-25 13:31 -0500
        Re: regex tidy "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-05-26 12:31 +0100

csiph-web