]>
Commit | Line | Data |
---|---|---|
8868edaf CR |
1 | # This program is free software: you can redistribute it and/or modify |
2 | # it under the terms of the GNU General Public License as published by | |
3 | # the Free Software Foundation, either version 3 of the License, or | |
4 | # (at your option) any later version. | |
5 | # | |
6 | # This program is distributed in the hope that it will be useful, | |
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 | # GNU General Public License for more details. | |
10 | # | |
11 | # You should have received a copy of the GNU General Public License | |
12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
13 | # | |
d233b485 CR |
14 | # pattern matching and replacement operators with multibyte characters |
15 | ||
16 | LANG=en_US.UTF-8 | |
17 | ||
18 | s1='abcådef' | |
19 | s2='Ã¥' | |
20 | s3='ḅć' | |
21 | ||
22 | s23=${s2}${s3} | |
23 | ||
24 | echo ${s1/$s2/xxx} | |
25 | echo ${s1/$s3/xxx} | |
26 | ||
27 | echo ${s23/#$s2/} | |
28 | echo ${s23/%$s3/} | |
29 | ||
30 | echo ${s23/#$s2/prepend} | |
31 | echo ${s23/%$s3/append} | |
32 | ||
33 | echo ${s2/#/prepend} | |
34 | echo ${s3/%/append} | |
35 | ||
36 | echo ${s2/#/} | |
37 | echo ${s3/%/} | |
38 | ||
39 | recho ${s2/$s2/} | |
40 | recho ${s3/$s3/} | |
41 | ||
42 | # posix pattern replacements | |
43 | ||
44 | echo ${s23##$s2} | |
45 | echo ${s23#$s2} | |
46 | ||
47 | echo ${s23%%$s3} | |
48 | echo ${s23%$s3} | |
49 | ||
50 | # fail | |
51 | ||
52 | echo ${s2/#ab/xx} | |
53 | echo ${s3/%ab/xx} | |
54 | ||
55 | echo ${s2#ab} | |
56 | echo ${s2##ab} | |
57 | ||
58 | echo ${s3%ab} | |
59 | echo ${s3%%ab} |