- 论坛徽章:
- 0
|
...
你 man awk里面有介绍
gensub(r, s, h [, t]) Search the target string t for matches of the regular expression r. If h is a string beginning with g or
G, then replace all matches of r with s. Otherwise, h is a number indicating which match of r to replace.
If t is not supplied, $0 is used instead. Within the replacement text s, the sequence \n, where n is a
digit from 1 to 9, may be used to indicate just the text that matched the n’th parenthesized subexpression.
The sequence \0 represents the entire matched text, as does the character &. Unlike sub() and gsub(), the
modified string is returned as the result of the function, and the original target string is not changed.
和gsub用法几乎一样多了个h
c=gsub(/ 规则 /,"要替换的字符","要替换第几个匹配的(g全部替换)数字",位置$0,$几)
呵呵不改变原来的
返回修改过的给c
最后print c就ok了 |
|