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


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

Re: regex tidy

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: regex tidy
Date Sat, 24 May 2014 14:55:03 +0200
Lines 49
Message-ID <bubj58Fn42U1@mid.individual.net> (permalink)
References <375vn9th0bc1faa04eg136be53hbvfjq4v@4ax.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net Yv4u4Dt2ycUsYGcsnxXNSgP8xFxhpwSKr84cEYm5LnCcANoZc=
Cancel-Lock sha1:eEV+HKLytxfmkGAI2oBnuDwfCKY=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
In-Reply-To <375vn9th0bc1faa04eg136be53hbvfjq4v@4ax.com>
Xref csiph.com comp.lang.java.programmer:28553

Show key headers only | View raw


On 23.05.2014 20:39, Roedy Green wrote:
> What would a Java regex tidier do?
>
> Here are some ideas:
>
> 1. remove nugatory \ quoting
>
> 2. convert \s*\s* --> \s*

More generally convert

R*R* into R*

But who writes regexes like this?

> 3. alphabetise | lists.

What does that mean?  Are you talking about merging common prefixes to 
get a more efficient matching experience?  That might actually be done 
by a regex engine if it detects this situation.

> 4. remove (?:... ) that is not doing anything.

Hmm...  It may still serve the purpose of documentation for the human.

> 5. put [..] lists in canonical order.

I don't believe this will improve anything.

> 6. Convert runs of 4+ to a-d notation.

Not sure what you mean here.

> 7. use negative char lists when it would shorten the list.

I don't believe this has any impact as this is something the regex 
engine will do internally.  Also, if the list is longer the way it is 
written then someone probably had a reason to do so.  Who would 
voluntarily write longer char classes than necessary?

Generally I tend to agree with what Leif wrote: it may actually be 
harder to read a regex that you did not author.  I am sceptical of the 
effort.  And then, you must consider that some changes may actually hurt 
performance if the regex was specifically crafted for a particular engine.

Kind regards

	robert

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