Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #28552
| From | Joshua Cranmer 🐧 <Pidgeot18@verizon.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: regex tidy |
| Date | 2014-05-23 15:05 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <llo9mp$ej7$1@dont-email.me> (permalink) |
| References | <375vn9th0bc1faa04eg136be53hbvfjq4v@4ax.com> <o9GdnRy5BZPqP-LOnZ2dnUVZ7vGdnZ2d@giganews.com> |
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
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