pike.ida.liu.se
Not logged in

The functions sprintf and sscanf will be presented in their own sections, below.

  • Check if it is a string
    stringp(something)

    The function stringp returns 1 if the value something is a string, otherwise 0.

  • Finding the size

    sizeof(string) or strlen(string)

    Returns the length (that is, the number of characters) in the string string.

    sizeof("hi ho") gives the result 5. sizeof("") gives the result 0.

    The function strlen is a synonym for sizeof.

  • Reversing a string

    reverse(string) returns a new string with the characters in reverse order.

    reverse("foo") gives the result "oof".

  • Replacing parts in a string

    replace(string, old, new) returns a new string where all occurrences of the string old have been replaced with the string new:

    replace("fooFOOfoo", "foo", "fum") gives the result "fumFOOfum".

  • Converting to lower case

    lower_case(string) returns a new string where all upper-case characters in the string string have been turned to lower case:

    lower_case("A Foo IS!") gives the result "a foo is!".

  • Converting to upper case

    upper_case(string) returns a new string where all lower-case characters in the string string have been turned to upper case:

    upper_case("A Foo IS!") gives the result "A FOO IS!".

  • Capitalizing
    String.capitalize(string)

    If the first character in the string string is a lower-case character, it is converted to upper case:

    String.capitalize("xyz-Foo") gives the result "Xyz-Foo".

  • Finding a substring in a string

    search(haystack, needle) returns the index of the start of the first occurrence of the string needle in the string haystack:

    search("sortohum", "orto") gives the result 1.