alfie has asked for the wisdom of the Perl Monks concerning the following question:
A dear friend of me asked me for a very special regular
expression problem, which I tried to solve. It goes like
this:
He needs to extract every character that resides between
two x in a string. So that would make xaxlxfxixex -> alfie.
Now the problem is, that it should also work with x
inbetween. So I tried a little here and there, and the best
I could came up with is the following:
So, I am missing the f in the output... So, what happened here? I'm slightly confused. Thanks for any hint you can offer.alfie:~$ perl -ne 'while (m/\G[^x]*?x(.)(?=x)/g) {print $1;}' xaxbxcxdexfx abc
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: special regexp
by Corion (Patriarch) on Mar 26, 2001 at 11:44 UTC | |
by alfie (Pilgrim) on Mar 26, 2001 at 12:05 UTC | |
by danger (Priest) on Mar 26, 2001 at 12:30 UTC | |
|
(Ovid) Re: special regexp
by Ovid (Cardinal) on Mar 26, 2001 at 12:42 UTC | |
|
Re: special regexp
by mirod (Canon) on Mar 26, 2001 at 13:36 UTC | |
|
Re: special regexp
by jeroenes (Priest) on Mar 26, 2001 at 12:48 UTC | |
by jorg (Friar) on Mar 26, 2001 at 13:32 UTC | |
by jeroenes (Priest) on Mar 26, 2001 at 13:49 UTC | |
by jorg (Friar) on Mar 26, 2001 at 14:02 UTC | |
by jeroenes (Priest) on Mar 26, 2001 at 14:45 UTC | |
by nysus (Parson) on Mar 26, 2001 at 13:52 UTC | |
|
Re: special regexp
by nysus (Parson) on Mar 26, 2001 at 13:14 UTC |