Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: regex tidy Date: Sun, 25 May 2014 18:49:41 +0200 Lines: 32 Message-ID: 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 J70AugWCprdfOcNXCYEN6gbhZbpb8D7bKhsUk3eVwHpHUhDTA= Cancel-Lock: sha1:7w2oUAX9mDZWSmQ0OFhIh22smN4= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:28558 On 25.05.2014 18:09, Roedy Green wrote: > On Sat, 24 May 2014 14:55:03 +0200, Robert Klemme > wrote, quoted or indirectly quoted > someone who said : >>> 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. > > > (cat|rabbit|dog|cow) > could be transformed to > (cat|cow|dog|rabbit) > > for two reasons: > make the list easier to proofread > might help engine optimise handling the c in cat and cow in common. The engine does not need the reordering to do this optimization. If you want to help lesser engines which do not optimize here you would have to transform it into (c(?:at|ow)|dog|rabbit) to get more efficient matching. Cheers robert