source: branches/lib/HELP_SOURCE/source/srt.hlp

Last change on this file was 19575, checked in by westram, 3 weeks ago
  • reintegrates 'help' into 'trunk'
    • preformatted text gets checked for width now (to enforce it fits into the arb help window).
    • fixed help following these checks, using the following steps:
      • ignore problems in foreign documentation.
      • increase default help window width.
      • introduce control comments to
        • accept oversized preformatted sections.
        • enforce preformatted style for whole sections.
        • simply define single-line preformatted sections
          Used intensive for definition of internal script languages.
    • fixed several non-related problems found in documentation.
    • minor layout changes for HTML version of arb help (more compacted; highlight anchored/all sections).
    • refactor system interface (GUI version) and use it from help module.
  • adds: log:branches/help@19532:19574
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1#       main topics:
2UP      arb.hlp
3UP      glossary.hlp
4
5#       sub topics:
6SUB     reg.hlp
7
8TITLE   Search and Replace Tool (SRT)
9
10
11DESCRIPTION     The String Parser is used to search and replace substrings.
12
13
14OCCURRENCE      TREE/Species/Search:PARSE FIELD
15                TREE/Properties/NDS
16
17
18SECTION         SYNTAX
19
20        Basic search replace command:
21
22# PREFORMATTED 1
23                'search=replace'
24
25                searches all occurrences of 'search' and replace each by 'replace'
26
27        Multiple search/replace commands can be separated by the character ':':
28
29# PREFORMATTED 1
30                'search1=replace1:search2=replace2: ... :searchn=replacen'
31
32                first searches all 'search1' and replaces each with 'replace1',
33                then searches all 'search2' and replaces each with 'replace2',
34                and so on.
35
36                The order of the SRT commands will affect the result.
37                Examples:
38                 * 'i=o:a=i' replaces all 'i' by 'o' and all 'a' by 'i'.
39                 * 'a=i:i=o' effectively replaces all 'a' and all 'i' by 'o'.
40                   Each 'a' first gets replaced by 'i', which later gets replaced by 'o'.
41
42SECTION SPECIAL CHARACTERS
43
44        Search && Replace string:
45
46                ':'                separates two commands
47                '='                separates the search from the replace string
48                '\'                Escape symbol
49                '\\'               the '\' symbol itself
50                '\n'               newline
51                '\t'               tabulator
52                '\:'               ':' (w/o special meaning)
53                '\='               '=' (--- " ---)
54                '\?'               '?' (--- " ---)
55                '\*'               '*' (--- " ---)
56
57        Search string:
58
59                '?'                single letter wildcard
60                '*'                multi letter wildcard
61
62        Replace string:
63
64# PREFORMATTED 1
65                '?'
66
67                        inserts the character which matched the corresponding single
68                        letter wildcard ('?') in the search string.
69                        Inserts a '?' if there is no corresponding wildcard.
70                        Does not apply if a digit or '(' follows.
71
72# PREFORMATTED 1
73                '?n'
74
75                        inserts the character which matched the n'th single
76                        letter wildcard in the search string.
77                        Inserts a '?' if there is no corresponding wildcard.
78                        n = { 1,...,9 }
79
80# PREFORMATTED 1
81                '*'
82
83                        inserts the substring which matched the corresponding multi
84                        letter wildcard ('*') in the search string.
85                        Inserts a '*' if there is no corresponding wildcard.
86                        Does not apply if a digit or '(' follows.
87
88# PREFORMATTED 1
89                '*n'
90
91                        inserts the substring which matched the n'th multi
92                        letter wildcard in the search string.
93                        Inserts a '*' if there is no corresponding wildcard.
94                        n = { 1,...,9 }
95
96# PREFORMATTED 1
97                '*(key)'
98
99                        inserts the value of the database field named 'key'
100                        (or an empty string, if value is empty or missing)
101
102# PREFORMATTED 1
103                '*([key]#default)'
104
105                        inserts the value of the database field named 'key'
106                        (or 'default', if value is empty or missing)
107
108# PREFORMATTED 1
109                '*([key]\:SRT)'
110
111                        reads the value of the database field named 'key',
112                        applies the SRT on that value
113                        and inserts the result.
114
115# PREFORMATTED 1
116                '*([key]|ACI)'
117
118                        reads the value of the database field named 'key',
119                        applies the LINK{aci.hlp} ACI on that value
120                        and inserts the result.
121
122# PREFORMATTED 1
123                '*([key]|/REG/)'
124
125                        reads the value of the database field named 'key',
126                        applies the LINK{reg.hlp} REG on that value
127                        and inserts the result.
128                        Also allows replace by regular expression using '/REG/replace/'.
129
130
131                Notes:
132                * all above '*(key...)'-constructs read the content of DB field 'key'.
133                * an empty string is used instead, if
134                  * the field does not exists, or
135                  * no fieldname is specified.
136                    Skipping the fieldname is possible where '[key]' is used in the description above.
137                * '?(key...)' does the same as '*(key...)'
138                * the SRT, ACI and REG expressions used in '*(key...)' require escaping of the
139                  characters ':', '=', '\', '*' and '?' by prefixing a '\'.
140                  Nesting SRT expressions require additional levels of escaping (i.e. ':' -> '\:' -> '\\\:' -> '\\\\\\\:').
141                * if an error occurs, the error message is inserted as result.
142                  When used for LINK{props_nds.hlp} such an error often gets truncated.
143                  Increasing the width of the display field helps to see the whole error message.
144
145EXAMPLES
146
147                Below you find some examples of SRT expressions.
148
149# PREFORMATTED 1
150                'p?r=p?w'
151
152                        replaces all 'par' to 'paw', 'pbr' to 'pbw', 'pcr' to 'pcw', ...
153
154# PREFORMATTED 1
155                'p??r=p?2?1r'
156
157                        swaps the two letters between p and r
158
159# PREFORMATTED 1
160                'a*=b*'
161
162                        replaces only the first 'a' by 'b'
163
164# PREFORMATTED 1
165                'a=b'
166
167                        replaces all 'a' by 'b'
168
169# PREFORMATTED 1
170                '?* *=?. *2'
171
172                        replaces the first word by its first letter + '.'
173
174# PREFORMATTED 1
175                '\:=\n'
176
177                        replaces all ':' by <newline>
178
179# PREFORMATTED 1
180                '*=* *(key1)'
181
182                        appends the database field <key1>.
183                        If <key1> does not exist, append a single space.
184
185# PREFORMATTED 1
186                '*=* *(key1):* =*'
187
188                        appends the database field <key1>.
189                        If <key1> does not exist, append a single space.
190                        The second expression removes such a trailing space again.
191
192# PREFORMATTED 1
193                '*=* *(key1#no info)'
194
195                        appends the database field <key1>.
196                        If <key1> does not exist, then append 'no info'.
197
198# PREFORMATTED 1
199                '*=*(key2\: =)'
200
201                        replace the whole input with the value of 'key2',
202                        with all spaces removed.
203
204# PREFORMATTED 1
205                '*=*(key2|remove(.-))'
206
207                        replace the whole input with the value of the database entry
208                        'key2', with all '.' and '-' characters removed.
209
210WARNINGS
211                Be careful when search or replace string contain
212                special characters (such as ':'). Avoid to write too
213                complicated commands.
214
215BUGS
216                None
Note: See TracBrowser for help on using the repository browser.