$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?)
In reply to regex search by zuma53
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |