sbs()

Read(1517) Label: sbs,

Here’s how to use the sbs() function.

k.sbs()

Description:

Get an integer consisting of certain bytes of a serial byte key.

Syntax:

k.sbs(a:b,…)

Get the integer made up of bytes from the ath to the bth in serial byte key k

Note:

The function gets a certain byte a or certain bytes from a to b to form an integer.

Parameter:

k

A serial byte key

a

The ath byte of serial byte k; begin from the first byte when this parameter is absent

b

The bth byte of serial byte k; stop at the last byte when this parameter is absent, and get the ath byte only when :b is absent

Return value:

Integer

Example:

k(4,5,6,8).sbs(2)

5; get the second byte from serial byte key k(4,5,6,8) to generate an integer.

k(4,5,6,8).sbs(1:3)

263430; get the bytes from 1 to 3 from serial byte key k(4,5,6,8) to generate an integer.

k(4,5,6,8).sbs(2:)

329224; get bytes from the second to the end from serial byte key k(4,5,6,8) to generate an integer.

k(4,5,6,8).sbs(:4)

67438088; get byte from the second to the fourth from serial byte key k(4,5,6,8) to generate an integer.

s.sbs()

Description:

Get multiple substrings from a string to form a new string.

Syntax:

s.sbs(a:b,…)

Note:

The function gets multiple substrings from string s to form a new string.

Parameter:

s

The source string from which substrings are to be obtained.

a

The start position where substrings are obtained; it is the a-to-last when a<0; default is 1.

b

The end position where substrings end; it is the b-to-last when a<0; let be=s.len() when b>s.len() or b is absent; let b=a when :b is absent.

Return value:

String

Example:

 

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"