Melang

Logo

A script language of preemptive scheduling coroutine in single thread

View the Project on GitHub Water-Melon/Melang

String

mln_bin2hex

Binary bytes string to hex string.

@mln_bin2hex(bin);

Input:

Return value:

Example:

@mln_print(@mln_bin2hex(@mln_rc4('HI', 'key')));

Output:

4325
mln_hex2bin

Hex string to binary bytes.

@mln_hex2bin(hex);

Input:

Return value:

Example:

@mln_print(@mln_hex2bin('4849'));

Output:

HI
mln_bin2int

Binary bytes to an integer.

@mln_bin2int(bin);

Input:

Return value:

Example:

@mln_print(@mln_bin2int('HI'));

Output:

18505
mln_int2bin

Integer to binary bytes.

@mln_int2bin(i);

Input:

Return value:

Example:

@mln_print(@mln_int2bin(18505));

Output:

HI
mln_bin2real

Binary bytes to real number.

@mln_bin2real(bin);

Input:

Return value:

Example:

@mln_print(@mln_bin2real('HI'));

Output:

1070435769529469910793714477087121352287059968.000000
mln_real2bin

Real number to binary bytes.

@mln_real2bin(r);

Input:

Return value:

Example:

@mln_print(@mln_real2bin(1070435769529469910793714477087121352287059968.000000));

Output:

HI
mln_b2s

Copy binary bytes into a string.

@mln_b2s(bin);

Input:

Return value:

Example:

@mln_print(@mln_b2s(100));

Output:

d
mln_s2b

String to a given type value.

@mln_s2b(s, type);

Input:

Return value:

Example:

@mln_print(@mln_s2b('d', 'int'));

Output:

100
mln_strlen

Calculate string length.

@mln_strlen(s);

Input:

Return value:

Example:

@mln_print(@mln_strlen('this is a test'));

Output:

14
mln_split

Return part of a string.

@mln_split(s, offset, len);

Input:

Return value:

Example:

@mln_print(@mln_split('this is a test', -10));

Output:

 is a test
mln_slice

Split a string by a set of characters.

@mln_slice(s, seps);

Input:

Return value:

Example:

@mln_print(@mln_slice('this is a test', ' s'));

Output:

[thi, i, a, te, t, ]
mln_kmp

Find the first occurrence of a string by KMP algorithm.

@mln_kmp(s, pattern);

Input:

Return value:

Example:

@mln_print(@mln_kmp('this is a test', 'is'));

Output:

2
mln_strstr

Find the first occurrence of a string

@mln_strstr(s, pattern);

Input:

Return value:

Example:

@mln_print(@mln_strstr('this is a test', 'is'));

Output:

2
mln_strncmp

String comparison of the first n characters.

@mln_strncmp(s1, s2, n);

Input:

Return value:

Example:

@mln_print(@mln_strncmp('this is a test', 'is', 2));

Output:

false
mln_strcmp

String comparison.

@mln_strcmp(s1, s2);

Input:

Return value:

Example:

@mln_print(@mln_strcmp('drink', 'drink'));

Output:

true
mln_strcmpSeq

String comparison.

@mln_strcmpSeq(s1, s2);

Input:

Return value:

Example:

@mln_print(@mln_strcmpSeq('drinking', 'drink'));

Output:

1
mln_regEqual

Match string by a regular expression.

@mln_regEqual(exp, text);

Input:

Return value:

Example:

@mln_print(@mln_regEqual('.*', 'test'));
@mln_print(@mln_regEqual('.*ed', 'test'));

Output:

true
false
mln_regMatch

Match string by a regular expression and get matched string pieces.

@mln_regMatch(exp, text);

Input:

Return value:

Example:

@mln_print(@mln_regMatch('((this )*i(s)).*', 'this is a reg exp test.'));

Output:

[this , s, this is, this is a reg exp test., ]