描述:
取字符串的多个子串组成一个新字符串。
语法:
s.sbs(a:b,…)
取字符串s的多个子串组成一个新字符串。
参数:
s |
待获得子串的源串。 |
a |
获得子串的起始位置,a<0时表示倒数第a位,省略为1。 |
b |
获得子串的结束位置,b<0时表示倒数第b位,b>s.len()或b省略时令b=s.len(),:b省略时令b=a。 |
返回值:
字符串
示例:
|
A |
|
1 |
="abcdefgh".sbs(2:3) |
"bc" |
2 |
="abcdefgh".sbs(:3) |
"abc" |
3 |
="abcdefgh".sbs(3:) |
"cdefgh" |
4 |
="abcdefgh".sbs(3) |
"c" |
5 |
="abcdefgh".sbs(2:4,6:7) |
"bcdfg" |
6 |
="abcdefgh".sbs(-5:7) |
"defg" |
7 |
="abcdefgh".sbs(2:-3) |
"bcdef" |
8 |
="abcdefgh".sbs(3:10) |
"cdefgh" |