C
Charles DeRykus
Charles said:Charles DeRykus said:(e-mail address removed) wrote:
Is it possible to write a regular expression for this ?
Pattern: 999-99-999
Where 9 is any number from 0 to 9
[...]
maybe I'm missing something but seems like `index' should do it once
you've eliminated the irrelevant leading/trailing *'s:
my $pat = '999-99-999';
my ( $no_star = $some_str ) =~ s/\A\*//; $no_star =~ s/\*\z//;
print "match: $some_str" if index( $pat, $no_star ) == 0;
Not when "9 is any number from 0 to 9".
Hm,, I'm not sure why that'd invalidate this approach. If $pattern were
123-45-6789 for instance, this still works AFAICT.
Based on the OP's example, I was assuming that any match still needed to
capture exactly some subset of the pattern. I guess it was ambiguous
only to me...