| 1 | #Please insert up references in the next lines (line starts with keyword UP) |
|---|
| 2 | UP arb.hlp |
|---|
| 3 | UP glossary.hlp |
|---|
| 4 | |
|---|
| 5 | #Please insert subtopic references (line starts with keyword SUB) |
|---|
| 6 | SUB reg.hlp |
|---|
| 7 | |
|---|
| 8 | TITLE Search and Replace Tool (SRT) |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | DESCRIPTION The String Parser is used to search and replace substrings. |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | OCCURRENCE TREE/Species/Search:PARSE FIELD |
|---|
| 15 | TREE/Properties/NDS |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | SECTION SYNTAX |
|---|
| 19 | |
|---|
| 20 | 'search=replace' means search all occurrences of 'search' |
|---|
| 21 | and replace it by 'replace' |
|---|
| 22 | |
|---|
| 23 | Different search/replace commands can be separated by ':': |
|---|
| 24 | |
|---|
| 25 | 'search1=replace1:search2=replace2: ... :searchn=replacen' |
|---|
| 26 | |
|---|
| 27 | SECTION SPECIAL CHARACTERS |
|---|
| 28 | |
|---|
| 29 | Search && Replace string: |
|---|
| 30 | |
|---|
| 31 | ':' separates two commands |
|---|
| 32 | '=' separates the search from the replace string |
|---|
| 33 | '\' Escape symbol |
|---|
| 34 | '\\' the '\' symbol itself |
|---|
| 35 | '\n' newline |
|---|
| 36 | '\t' tabulator |
|---|
| 37 | '\:' ':' |
|---|
| 38 | '\=' '=' |
|---|
| 39 | '\?' '?' |
|---|
| 40 | '\*' '*' |
|---|
| 41 | |
|---|
| 42 | Search string: |
|---|
| 43 | |
|---|
| 44 | '?' single letter wildcard |
|---|
| 45 | '*' multi letter wildcard |
|---|
| 46 | |
|---|
| 47 | Replace string: |
|---|
| 48 | |
|---|
| 49 | '?' a reference to the corresponding single |
|---|
| 50 | letter wildcard in the search string |
|---|
| 51 | (if no digit or '(' follows). |
|---|
| 52 | '?n' n = { 1,...,9 } |
|---|
| 53 | a reference to the n'th single letter wildcard |
|---|
| 54 | in the search string |
|---|
| 55 | '*' a reference to the corresponding multi |
|---|
| 56 | letter wildcard in the search string |
|---|
| 57 | (no digit or '(' follows). |
|---|
| 58 | '*n' n = { 1,...,9 } |
|---|
| 59 | a reference to the n'th multi letter wildcard |
|---|
| 60 | in the search string |
|---|
| 61 | '*(key)' the value of the database field named 'key' (or '' - see below) |
|---|
| 62 | '*([key]#default)' value of DB field 'key' (if empty or missing -> return 'default') |
|---|
| 63 | '*([key]\:nsrt)' invokes the SRT recursively on the value of DB field 'key' (or on '') |
|---|
| 64 | (Note: all ':' have to be escaped using '\') |
|---|
| 65 | '*([key]|ACI)' invokes ACI (see LINK{aci.hlp}) on the value of DB field 'key' (or on '') |
|---|
| 66 | |
|---|
| 67 | Note: all above "*(key...)"-constructs read the content of DB field 'key'. |
|---|
| 68 | If no fieldname is specified (possible where '[key]' is used in the description above) |
|---|
| 69 | or if the field does not exists, an empty string is used instead. |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | EXAMPLES |
|---|
| 73 | 'p?r=p?w' |
|---|
| 74 | |
|---|
| 75 | replaces all par to paw |
|---|
| 76 | pbr to pbw |
|---|
| 77 | pcr to pcw ... |
|---|
| 78 | |
|---|
| 79 | 'p??r=p?2?1r' |
|---|
| 80 | |
|---|
| 81 | swaps the two letters between p and r |
|---|
| 82 | |
|---|
| 83 | 'a*=b*' |
|---|
| 84 | |
|---|
| 85 | replaces only the first 'a' by 'b' |
|---|
| 86 | |
|---|
| 87 | '?* *=?. *2' |
|---|
| 88 | |
|---|
| 89 | Replaces the first word by its first letter + '.' |
|---|
| 90 | |
|---|
| 91 | '\:=\n' |
|---|
| 92 | |
|---|
| 93 | replaces all ':' by <newline> |
|---|
| 94 | |
|---|
| 95 | '*=* *(key1)' |
|---|
| 96 | |
|---|
| 97 | appends the database field <key1>. |
|---|
| 98 | if <key1> does not exists append nothing |
|---|
| 99 | |
|---|
| 100 | '*=* *(key1#no info)' |
|---|
| 101 | |
|---|
| 102 | appends the database field <key1> |
|---|
| 103 | if <key1> does not exists append |
|---|
| 104 | 'no info' |
|---|
| 105 | |
|---|
| 106 | '*=*(key2\: =)' |
|---|
| 107 | |
|---|
| 108 | The value of 'key2' with all spaces removed |
|---|
| 109 | |
|---|
| 110 | '*=*(key2|remove(.-))' |
|---|
| 111 | |
|---|
| 112 | the value of the database entry 'key2', |
|---|
| 113 | but all '.' and '-' characters removed |
|---|
| 114 | |
|---|
| 115 | WARNINGS |
|---|
| 116 | Be careful when search or replace string contain |
|---|
| 117 | special characters (such as ':'). Avoid to write too |
|---|
| 118 | complicated commands. |
|---|
| 119 | |
|---|
| 120 | BUGS |
|---|
| 121 | None |
|---|