zuma53 has asked for the wisdom of the Perl Monks concerning the following question:
$A: abc.def.ghi $B: abcTo ask "does $A start with $B" is trivial:
$A =~ /^${B}/;
But what is the complement of this? That is, "is $B a prefix of $A?"
$B =~ /?$A?/;Here, I am taking the fact that $B is shorter than $A, but this logic fails when $B is longer than $A. I can probably do some clunky len/substring preprocessing, but I am certain there's a more elegant regex way (isn't there always?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex search
by AnomalousMonk (Archbishop) on Jun 19, 2012 at 16:59 UTC | |
|
Re: regex search
by aaron_baugher (Curate) on Jun 19, 2012 at 20:25 UTC | |
|
Re: regex search
by cheekuperl (Monk) on Jun 19, 2012 at 15:29 UTC | |
by zuma53 (Beadle) on Jun 19, 2012 at 15:36 UTC | |
by muba (Priest) on Jun 19, 2012 at 15:42 UTC | |
by zuma53 (Beadle) on Jun 19, 2012 at 16:23 UTC | |
by muba (Priest) on Jun 19, 2012 at 16:53 UTC | |
| |
|
Re: regex search
by muba (Priest) on Jun 19, 2012 at 19:10 UTC |