method s '' position -> c arg Str s ; arg Int position ; arg_C Char c
An example:
var Str s := "abc" s 1 := "B" console s eol
method s len -> l arg Str s ; arg Int l
return the lenth of the string.
method s '' first maximum -> sub arg Str s ; arg Int first maximum ; arg Str sub
returns the substring of 's' that starts at character with position 'first' and constains 'maximum' characters. 'first' must be positive but can be greater than the string length. 'maximum' must also be positive. If less that 'maximum' characters are available starting form 'first' position, the returned string will truncated, but it's ok.
method s search pattern if_not_found -> position arg Str s pattern ; arg Int if_not_found position method s search_last pattern if_not_found -> position arg Str s pattern ; arg Int if_not_found position
searches for the first (or last) occurrence of 'pattern' and returns its position.if 'pattern' was not found, then 'if_not_found' is return instead.
function replace original pattern with -> changed arg Str original pattern with changed
replaces all the occurrences of 'pattern' in 'original' by 'with'.
function repeat times pattern -> repeted arg Int times ; arg Str pattern repeted
repeats 'pattern' 'times' times.
function left original minimal_length pattern -> aligned arg Str original ; Int length ; arg Str pattern aligned
if 'original' length is greater or equal than 'minimal_length', then 'original' is returned unmodified,elsewhere 'original' length is extended to 'minimal_length' by repeating 'pattern' at the end of the string.Please notice that 'pattern' length must be 1.
function right original minimal_length pattern -> aligned arg Str original ; Int length ; arg Str pattern aligned
same, but 'pattern' is repeated at the beginning of the string.
function upper original -> upper_cased arg Str original upper_cased function lower original -> lower_cased arg Str original lower_cased
Returns a copy of 'original' where all unaccented characters have been turned to upper case (or lower case).
method string parse ... -> matching arg Str string ; arg CBool matching method string eparse ... -> matching arg Str string ; arg CBool matching
Tests if the string matches the given pattern. If 'parse' is used, the spaces or tabulations between the recognized items are removed, whereas they are not if 'eparse' is used.
This is an example:
var Str a := "abc def 12" var Str s ; var Int i if (a parse "abc" any:s i) console "s = " s eol console "i = " i eol
Since Pliant is perfectly orthogonal, you can also write it as:
if ("abc def 12" parse "abc" any:(var Str s) (var Int i)) console "s = " s eol console "i = " i eol
A string variable, if not put in an 'any' statement, is expected to be encoded with double quotes:
if ("abc [dq]def[dq] 12" parse "abc" (var Str s) (var Int i)) console "s = " s eol console "i = " i eol
function string data [options] -> str arg Universal data ; arg Str options str
console string:"abc" eol
"abc"
abc
method s characters -> adr arg Str s ; arg address adr
returns the address of the string characters.
method s set characters length allocated arg Str s ; arg address characters ; arg Int length ; arg CBool allocated
sets the string value. If 'allocated' is true, then the 'characters' area has been allocated using 'memory_allocate' function, whereas if 'allocated' is false, then 'characters' is pointing to an area belonging to another object.