Resources:
Http://gashero.yeax.com/?p=64
Http://gashero.yeax.com/?p=65
A) String
1.1 len (String), Length
String=string ()
Length
Returns the number of characters in a string. 1.2 equal (STRING1,STRING2), BOOL ()
String1=string2=string ()
Tests whether two strings are equal, returns false if equality returns True , and not equal. 1.3 concat (string1,string2), String3
String1=string2=string3=string ()
Concatenate two strings into a new string, returning a new string. 1.4 chr (string,character), Index
String=string ()
Character=char ()
Index=integer ()
Returns the position of the first occurrence of a character in a string, or 0 if it does not exist.
The function rchr has the same parameters but is calculated from the right. 1.5 str (string,substring), Index
String=substring=string ()
Index=integer ()
Returns the substring match location, and returns 0 if it does not match. For example:
> string:str ("Hello Hello World", "Hello World").
8
The function rstr has the same parameters but is calculated from the right. 1.6 span (string,chars), Length
String=chars=string ()
Length=integer ()
Returns a string that matches the maximum character length in chars, beginning with the previous. For example:
> String:span ("t abcdefg", "T").
5
> String:cspan ("t abcdefg", "T").
0
The function Cspan is the part that does not match the first match from the previous one. The following chars can contain multiple characters for matching. 1.7 substr (String,start[,length]), SubString
String=substring=string ()
Start=length=integer ()
Gets the substring of the string that can be specified at the beginning and length, and the length can be omitted. For example:
> String:substr ("Hello World", 4,5).
" Lo Wo "
1.8 Tokens (string,separatorlist), tokens
String=separatorlist=string ()
tokens=[string ()]
Cuts a string into lexical notation based on the characters in the delimited list of symbols. For example:
> String:tokens ("ABC Defxxghix JKL", "X").
["ABC", "Def", "Ghi", "JKL"]
1.9 chars (Character,number[,tail]), String
Character=char ()
Number=integer ()
string=string ()
Returns a string containing the specified number of characters, optionally specifying the string tail followed. 1.10 copies (string,number), copies
String=copies=string ()
Number=integer ()
Returns a string containing the specified number of copies copied. 1.11 Words (String[,character]), Count
String=string ()
Character=char ()
Count=integer ()
Returns the number of words in a string, which can be specified in the second optional parameter. For example:
> string:words ("Hello old boy!", $o).
4
Note the delimited character must begin with a dollar sign, followed by the $o above. 1.12 Sub_word (String,number[,character]) word
String=word=string ()
Character=char ()
Number=integer ()
Returns the word at the specified position, as defined by the delimiter between words. Note that the position number here starts with 1. For example:
> String:sub_word ("Hello old boy!", 3, $o).
" LD B "
1.13 Strip (String[,direction[,character]), stripped
String=stripped=string ()
Direction=left | right | both
Character=char ()
Returns a string that removes both whitespace and can specify direction and whitespace characters. STRIP/1 is equivalent to strip (String,both). For example:
> String:strip ("... Hello ... ", both,$.).
" Hello "
1.14 Left (String,number[,character])
String=left=string ()
Character=char
Number=integer ()
Returns a string that has been resized from the left to a specified number, and can be specified followed by a padding character, which defaults to a space. If the string is too long, it will not be truncated. For example:
> String:left ("Hello", 10,$.).
" Hello ... "
The function right has the same parameters, except that it aligns the strings to the left. 1.15 Centre (String,number[,character]), centered
String=centered=string ()
Character=char
Number=integer ()
Expands the middle alignment of a string to a specified length, without padding with spaces or specified characters. 1.16 sub_string (String,start[,stop]), SubString
String=substring=string ()
Start=stop=integer ()
Returns a substring of a string that can specify the starting and ending positions. For example:
> string:sub_string ("Hello World", 4,8).
" Lo Wo "
Note that unlike the specified start and length of the substr, this function is specified to start and end. 1.17 to_float (String), {float,rest} | {Error,reason}
String=string ()
float=float ()
rest=string ()
reason=no_float | not_a_list
Converts a string that starts with a floating-point number to a floating-point number, and the remaining unrecognized returns. For example:
> {f1,fs}=string:to_float ("1.0-1.0e-1"),
> {f2,[]}=string:to_float (Fs),
> F1+f2.
0.900000
> String:to_float ("3/2=1.5").
{Error,no_float}
> string:to_float (" -1.5ex").
{ -1.50000, "EX"}
1.18 To_integer (String), {int,rest} | {Error,reason}
String=string ()
Int=integer ()
rest=string ()
reason= No_integer | not_a_list
Converts a string that begins with an integer in an argument to an integer and the remainder. For example:
> {I1,is}=string:to_integer ("33+22"),
> {I2,[]}=string:to_integer (IS),
> I1-i2.
> String:to_integer ("0.5").
{0, ". 5"}
> String:to_integer ("x=2").
{Error,no_integer}
1.19 To_lower (String), Result
String=result=string ()
Char=charresult=integer ()
Converts a character or string into uppercase or lowercase form. Other forms:
To_lower (char), Charresult
to_upper (String), Result
To_upper (char), Charresult
B) RegExp
1.1 Match (STRING,REGEXP), Matchres
String=regexp=string ()
matchres={match,start,length} | nomatch | {Error,errordesc ()}
Start=length=integer ()
Looks for the first longest match of a regular expression regexp in string strings. The search is the longest possible match and returns the first if a few results are the same. Returned as follows: {match,start,length}: Match succeeded, return start and length. NoMatch: Unable to match. {Error,error}: Error occurred. 1.2 First_match (string,regexp), Matchres
String=regexp=string ()
matchres={match,start,length} | nomatch | {Error,errordesc ()}
Start=length=integer ()
Finding the first match, usually faster than match, and determining the presence or absence of a match. The return value is the same as match. 1.3 Matches (string,regexp), Matchres
String=regexp=string ()
Matchres={match,matchres} | {Error,errordesc ()}
Matchres=list ()
Returns all non-overlapping matching results, returned as follows: {match,matches}: If the regular expression is correct, the empty list is returned if there is no match. Each element is a tuple of the form {start,length}. {Error,error}: There is an error in the regular expression. 1.4 Sub (string,regexp,new), Subres
String=regexp=new=string ()
Subres={ok,newstring,repcount} | {Error,errordesc ()}
Repcount=integer
Replace the first substring that matches the successful one with new. The & symbol in the string new represents the replaced string, and & represents the original & symbol. Returns the result such as: {Ok,newstring,repcount}: If the regular expression is correct, the number of times the Repcount is replaced is 0 or 1. {Error,error}: The regular expression is incorrect. 1.5 gsub (string,regexp,new), Subres
Essentially equivalent to sub, except that all non-overlapping is replaced, not just one. 1.6 Split (STRING,REGEXP), Splitres
String=regexp=string ()
subres={ok,fieldlist} | {Error,errordesc ()}
Fieldlist=[string ()]
The string is cut into multiple fields by means of regular expressions. If the separator character is a space "", the delimited character also implicitly includes the tab character. Other separator characters do not have this effect. The return value is as follows: {ok,fieldlist}: The string has been cut into individual fields. {Error,error}: The regular expression is incorrect. 1.7 Sh_to_awk (shregexp), Awkregexp
Shregexp=awkregexp=string ()
Subres={ok,newstring,repcount} | {Error,errordesc ()}
Repcount=integer ()
Converts a regular expression of type sh to a regular expression of type awk. Returns the converted string. The SH regular expression is used by the shell to match the file name, and supports the following special characters:: Matches any number of characters? : Matches a single arbitrary character [...]: matches a range of characters, and the range of characters is delimited by symbols. If the first character is! Is the opposite of the match.
Although the SH regular expression is not powerful, it is useful most of the time. 1.8 Parse (REGEXP), Parseres
Regexp=string ()
Parseres={ok,re} | {Error,errordesc ()}
Converts the regular expression string to an internal format that can be used by other regular expression functions. You can replace the position of a regular expression when other functions are called. This is very effective when the same regular expression needs to be used more than once. Return value: {Ok,re}: Successful match returns internal notation. {Error,error}: The regular expression is incorrect. 1.9 Format_error (errordescription), Chars
Errordescriptor=errordesc ()
Chars=[char () | Chars]
A description of the matching error is returned when the match fails.