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


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

Re: regex replaceAll?

From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: regex replaceAll?
Date 2018-03-01 17:52 -0500
Organization Aioe.org NNTP Server
Message-ID <p7a07l$h4g$1@gioia.aioe.org> (permalink)
References (1 earlier) <slrnp9gjk6.5mg.avl@logic.at> <44c665e1-e965-4e9b-8aa0-72aa20607e63@googlegroups.com> <slrnp9gtn0.5mg.avl@logic.at> <8c677118-8115-409d-8d3b-396e54b063ae@googlegroups.com> <slrnp9gvpc.5mg.avl@logic.at>

Show all headers | View raw


On 3/1/2018 5:31 PM, Andreas Leitgeb wrote:
> It's pretty normal that some attempt at writing an RE to solve a problem
> doesn't work at first time.
> 
> Then, there's essentially two strategies:
> 
>   1) randomly shuffle around the funny symbols and see if that
>        works then.  If the reshuffled variant doesn't work, either,
>        go back to original and defend it: "tried other way, but
>        didn't work any better."
> 
>   2) analyze what the RE is really doing, and refine it to do
>        what you want it to do.
> 
> take your choice...
> 
> Also you're playing it the hard way, by building up your RE from
> fixed and variable parts. Start with constructing the RE for a specific
> char and n (literally writing "{2}" (for n==3)), and only after that
> works, then take it apart and assemble it from literal and variable parts.
> It's one thing to get an RE right, but a much harder thing to get some
> mix of RE and Java-expressions right from scratch.

RE are great for some things, but there are also cases where they
are not good.

Famous quote:

<quote>
Some people, when confronted with a problem, think "I know, I'll use 
regular expressions." Now they have two problems.
</quote>

Arne

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


Thread

regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-01 06:19 -0800
  Re: regex replaceAll? Andreas Leitgeb <avl@logic.at> - 2018-03-01 19:03 +0000
    Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-01 12:15 -0800
      Re: regex replaceAll? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-03-01 21:51 +0100
        Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-01 13:36 -0800
          Re: regex replaceAll? Arne Vajhøj <arne@vajhoej.dk> - 2018-03-01 16:59 -0500
      Re: regex replaceAll? Andreas Leitgeb <avl@logic.at> - 2018-03-01 21:55 +0000
        Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-01 14:00 -0800
          Re: regex replaceAll? Andreas Leitgeb <avl@logic.at> - 2018-03-01 22:31 +0000
            Re: regex replaceAll? Arne Vajhøj <arne@vajhoej.dk> - 2018-03-01 17:52 -0500
              Re: regex replaceAll? Andreas Leitgeb <avl@logic.at> - 2018-03-02 00:14 +0000
            Re: regex replaceAll? Kiwi User <martin@mydomain.invalid> - 2018-03-02 00:43 +0000
              Re: regex replaceAll? Arne Vajhøj <arne@vajhoej.dk> - 2018-03-01 19:49 -0500
                Re: regex replaceAll? Kiwi User <martin@mydomain.invalid> - 2018-03-02 01:33 +0000
                Re: regex replaceAll? Arne Vajhøj <arne@vajhoej.dk> - 2018-03-02 13:00 -0500
                Re: regex replaceAll? Kiwi User <martin@mydomain.invalid> - 2018-03-03 20:07 +0000
            Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-02 05:40 -0800
              Re: regex replaceAll? Andreas Leitgeb <avl@logic.at> - 2018-03-02 17:46 +0000
                Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-02 10:38 -0800
                Re: regex replaceAll? Andreas Leitgeb <avl@logic.at> - 2018-03-02 20:15 +0000
                Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-02 12:43 -0800
                Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-02 12:58 -0800
                Re: regex replaceAll? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-03-03 00:06 +0100
  Re: regex replaceAll? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-03-01 20:29 +0100
    Re: regex replaceAll? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-03-01 20:30 +0100
    Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-01 12:28 -0800
      Re: regex replaceAll? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-03-01 21:40 +0100
    Re: regex replaceAll? Eric Douglas <e.d.programmer@gmail.com> - 2018-03-01 13:52 -0800
      Re: regex replaceAll? Daniele Futtorovic <da.futt.news@laposte.net> - 2018-03-02 02:25 +0100

csiph-web