Yesterday I wrote:
> Paul Makepeace writes:
>
> > On Tue, Dec 3, 2013 at 5:03 PM, Mark Fowler
> > wrote:
> >
> > > On Tue, Dec 3, 2013 at 6:54 PM, Paul Makepeace
> > > wrote:
> > >
> > > > $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
> > >
> > > This is where tools like Regexp::Debugger
On Tue, Dec 3, 2013 at 11:55 PM, Paul Makepeace wrote:
> Construct an elegant* regex (in perl!) to ensure the end of the string
> contains "string":
>
> is(fqdn('foo'), 'foo.example.com')
> is(fqdn('foo.example.com'), 'foo.example.com')
Maybe I'm just slow, but I see no relation between that task
Matt Lawrence writes:
> It looks like Python has decided that a zero-width match cannot
> immediately follow a non-zero-width match.
Thanks.
That sounds like a special-case exception to me, increasing the
complexity of understanding how patterns match.
But in practice it might be less surprisin
On 04/12/13 10:15, Smylers wrote:
I agree the behaviour isn't immediately obvious. But it does make sense
when thinking about what each component means separately.
So what does seem bug-like to me is the Python behaviour — can anybody
explain that?
It looks like Python has decided that a zero-w
Paul Makepeace writes:
> On Tue, Dec 3, 2013 at 5:03 PM, Mark Fowler wrote:
>
> > On Tue, Dec 3, 2013 at 6:54 PM, Paul Makepeace
> > wrote:
> >
> > > $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
> >
> > This is where tools like Regexp::Debugger shine. Running
> >
> > perl -le 'use Regex
On 04/12/13 07:55, Paul Makepeace wrote:
On Tue, Dec 3, 2013 at 5:03 PM, Mark Fowler wrote:
On Tue, Dec 3, 2013 at 6:54 PM, Paul Makepeace wrote:
$ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
This is where tools like Regexp::Debugger shine. Running
perl -le 'use Regexp::Debugger; (
On 04/12/13 07:55, Paul Makepeace wrote:
* I realise this is hilariously open to interpretation but you'll know
what I mean either way
http://geek-and-poke.com/geekandpoke/2013/12/3/yesterdays-regex
;-)
On Tue, Dec 3, 2013 at 5:03 PM, Mark Fowler wrote:
> On Tue, Dec 3, 2013 at 6:54 PM, Paul Makepeace wrote:
>
>> $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
>
> This is where tools like Regexp::Debugger shine. Running
>
> perl -le 'use Regexp::Debugger; ($a = "aabbb") =~ s/b*$/c/g; print
On Tue, Dec 3, 2013 at 6:54 PM, Paul Makepeace wrote:
> $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
This is where tools like Regexp::Debugger shine. Running
perl -le 'use Regexp::Debugger; ($a = "aabbb") =~ s/b*$/c/g; print $a'
Shows exactly why it gives the output it does (if you hit
On 04/12/2013 08:54, Paul Makepeace wrote:
$ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
Why... oh. That's clever. Yes.
For those like me who are slow and can't immediately see why that does what it
does, here are some hints:
What does perl -le '($a = "aabbb") =~ s/b+$/c/g; print $a' d
On 3 Dec 2013, at 23:54, Paul Makepeace wrote:
> What does this output?
>
> $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a’
You can tell you’ve been writing perl too long when you know what that’s going
to do and why :(
Here’s your example modified to exhibit my favourite regex madness. Ca
On Tue, Dec 3, 2013 at 3:54 PM, Paul Makepeace wrote:
> What does this output?
>
> $ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
>
> Cunning multilinguists may also answer the same question of these,
> (which nominally do the same thing)
>
> $ ruby -e 'p "aabbb".gsub(/b*$/, "c")'
>
> $ python
What does this output?
$ perl -le '($a = "aabbb") =~ s/b*$/c/g; print $a'
Cunning multilinguists may also answer the same question of these,
(which nominally do the same thing)
$ ruby -e 'p "aabbb".gsub(/b*$/, "c")'
$ python -c "import re; print re.sub(r'b*$', 'c', 'aabbb')"
Enjoy...
Paul
13 matches
Mail list logo