- 论坛徽章:
- 0
|
比如重命名为www.
s/(\w+)\(/www\(/g;
不知道理解对不对
你可以看看这个。
?: 表示非捕获符号。就是什么也不匹配。
(?!pattern) 如果正则表达式在后面不匹配 pattern ,才会开始匹配。如/foo(?!bar)/,只有当出现 foo,并且后面不出现 bar 时才开始匹配.
Type Regex Successful if the enclosed subexpression ...
Positive Lookbehind (?<=......) successful if can match to the left #例子:"abcdefg" =~ m/(?<=c)/;
print $`,$&,$';
Negative Lookbehind (?<!......) successful if can not match to the left
Positive Lookahead (?=......) successful if can match to the right #例子: "abcdefg" =~ m/(?=c)/;
print $`,$&,$';
Negative Lookahead (?!......) successful if can not match to the right
Example Showing After-Match Special Variables After the match of
12 2 3 4 4 31
"Pi is 3.14159, roughly" =~ m/\b((tasty|fattening)|(\d+(\.\d*)?))\b/;
the following special variables are given the values shown.
Variable Meaning Value
$' Text before match Pi?is?
$& Text matched 3.14159
$' Text after match , ?roughly
$1 Text matched within 1st set of parentheses 3.14159
$2 Text matched within 2nd set of parentheses undef
$3 Text matched within 3rd set of parentheses 3.14159
$4 Text matched within 4th set of parentheses .14159
$+ Text from highest-numbered $1, $2, etc. .14159
$^N Text from most recently closed $1, $2, etc. 3.14159
@- Array of match-start indices into target text (6, 6, undef, 6, 7)
@+ Array of match-end indices into target text (13, 13, undef, 13, 13) |
|