File: replace-string.2gg

package info (click to toggle)
golf 601.4.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,824 kB
  • sloc: ansic: 20,020; sh: 1,171; makefile: 292
file content (98 lines) | stat: -rw-r--r-- 2,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
replace-string \-  (strings)
.SH PURPOSE
Replaces part of string.

.SH SYNTAX

.RS 4
.EX

replace-string <string> \\
    ( copy <replacement> ) | ( copy-end <replacement> ) \\
    [ start-with <start with> ] \\
    [ length <length> ] 

.EE
.RE

.SH DESCRIPTION
replace-string will replace part of <string> with <replacement> string. "copy" clause will make a replacement in the leading part of <string>, while "copy-end" will make a replacement in the trailing part of <string>.

If "length" clause is not used, then the entire <replacement> string is used, otherwise only the <length> leading bytes of it.

If "start-with" clause is used, then <replacement> will be copied starting with byte <start with> in <string> ("0" being the first byte) (with "copy" clause) or starting with <start with> bytes prior to the end of <string> (with "copy-end" clause).

If "start-with" clause is not used, then <replacement> will replace the leading part of <string> (with "copy" clause") or the very last part of <string> (with "copy-end" clause). In either case, the number of bytes copied is determined by whether "length" clause is used or not.

If either "start-with" or "length" is negative, it's the same as if not specified. 

.SH EXAMPLES
After replace-string below, string "a" will be "none string is here":

.RS 4
.EX

set-string b="none"
set-string a="some string is here"
replace-string a copy b

.EE
.RE

After replace-string below, string "a" will be "some string is none":

.RS 4
.EX

set-string b="none"
set-string a="some string is here"
replace-string a copy-end b

.EE
.RE

In this example, "a" will be "somnontring is here":

.RS 4
.EX

set-string b="none"
set-string a="some string is here"
replace-string a copy b start-with 3 length 3

.EE
.RE

In the following example, "a" will be "some string inohere":

.RS 4
.EX

set-string b="none"
set-string a="some string is here"
replace-string a copy-end b start-with 6 length 2

.EE
.RE

.SH SEE ALSO
 Strings

\fBconcatenate-strings\fP  
\fBcopy-string\fP  
\fBcount-substring\fP  
\fBdelete-string\fP  
\fBlower-string\fP  
\fBnew-string\fP  
\fBread-split\fP  
\fBreplace-string\fP  
\fBset-string\fP  
\fBsplit-string\fP  
\fBstring-length\fP  
\fBtrim-string\fP  
\fBupper-string\fP  
\fBwrite-string\fP   
See all 
\fBdocumentation\fP