Rev 5921 | Rev 11212 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5921 | Rev 11210 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | !! +exec+ +var+ +string+ |
1 | !! +exec+ +var+ +string+ |
2 |
|
2 | tit:replace |
3 | $(lst_syntax)replace [internal] $emph s1 $emphend by $emph s2 $emphend in $emph |
- | |
4 |
|
3 | type:$type_both |
5 |
|
4 | syntax:!replace [internal] `s1' by `s2' in `string'<br/>\ |
6 |
|
5 | or <span class="tt">!replace `obj' `ident' by `s' in `string'</span> |
7 |
|
6 | mean:String manipulation. <p>\ |
8 | Under the first |
7 | Under the first syntax, variable substitution is first done on `string'.\ |
9 |
|
8 | Then all occurences of substring `s1' are replaced by `s2'. <br/>\ |
10 | are replaced by $emph s2$emphend. <br/> |
- | |
11 | When the keyword $emph internal $emphend is absent, |
- | |
12 | the |
9 | When the keyword `internal' is absent, the Linux utility `sed' is called to make the replacements,\ |
13 | therefore regular expressions are accepted in |
10 | therefore regular expressions are accepted in `s1' and `s2'.\ |
14 |
|
11 | Please refer to the man page of `sed' for details. </p><p>\ |
15 | details. </p><p> |
- | |
16 | Under the second |
12 | Under the second syntax, `obj' can be `char', `word', `item' or `line'.\ |
17 | $emph word$emphend, |
- | |
18 | $emph item$emphend or $emph line$emphend. Then the word, item or line |
- | |
19 |
|
13 | Then the word, item or line identified by `ident' in `string' is replaced\ |
20 | by |
14 | by `s', after variable substitutions. <br/>\ |
21 |
|
15 | `ident' can be a string, in this case all objects (words, items or lines) matching `ident' \ |
22 | (words, items or lines) matching |
- | |
23 |
|
16 | will be replaced. It can also be a number (positive or negative integer `n'), preceded\ |
24 | negative integer $emph n$emphend), preceded |
- | |
25 | by the word |
17 | by the word `number'. In this case the object number `n' will be replaced.\ |
26 | number $emph n$emphend will be replaced. (In the case where n<0, |
- | |
27 | it is the last -n'th object which is replaced.) |
18 | (In the case where n<0, it is the last -n'th object which is replaced.)\ |
28 | </p> |
19 | </p> |