- 论坛徽章:
- 145
|
回复 3# pony2001mx
$ perl -le '$a="a-afoa-fd--f----a";$a=~s/(\w)(?=\w)/${1}0/g;print $a'
a-a0f0o0a-f0d--f----a
more detail information
$ perldoc perlre
NAME
perlre - Perl regular expressions
DESCRIPTION
This page describes the syntax of regular expressions in Perl.
...
Look-Around Assertions
Look-around assertions are zero-width patterns which match a
specific pattern without including it in $&. Positive assertions
match when their subpattern matches, negative assertions match
when their subpattern fails. Look-behind matches text up to the
current match position, look-ahead matches text following the
current match position.
"(?=pattern)"
A zero-width positive look-ahead assertion. For example,
"/\w+(?=\t)/" matches a word followed by a tab, without
including the tab in $&.
...
|
|