Did you know ... Search Documentation:
Pack prolog_library_collection -- prolog/string_ext.pl
PublicShow source

Extends the string support in the SWI-Prolog standard library.

 max_string_length(+Strings:list(string), -Max:nonneg) is det
 message_lines(+Message:string, +MaxLength:positive_integer, -Lines:list(string)) is det
 read_string(+In:istream, -String:string) is det
Wrapper for read_string/3 when the number of read characters does not matter.
 split_string(+String:string, +SepChars:string, +SubStrings:list(string)) is semidet
split_string(+String:string, +SepChars:string, -SubStrings:list(string)) is det
 string_code(+String:string, +Code:atom) is semidet
string_code(+String:string, -Code:atom) is det
string_code(-String:string, +Code:atom) is det
 string_ellipsis(+Original:string, +MaxLength:between(2,inf), +Ellipsed:string) is semidet
string_ellipsis(+Original:string, +MaxLength:between(2,inf), -Ellipsed:string) is semidet
string_ellipsis(+Original:string, -MaxLength:between(2,inf), -Ellipsed:string) is nondet
Succeeds if Ellipsed is like Orginal, but has ellipsis applied in order to have MaxLength. If Original is not longer than MaxLength, Orignal and Ellipsed are the same.
?- string_ellipsis("monkey", Length, Ellipsed).
Length = 2,
Ellipsed = "m…" ;
Length = 3,
Ellipsed = "mo…" ;
Length = 4,
Ellipsed = "mon…" ;
Length = 5,
Ellipsed = "monk…" ;
Length = 6,
Ellipsed = "monkey".
See also
- atom_ellipsis/3 provides the same functionality for atoms.
 string_list_concat(+Strings:list(string), +String:string) is semidet
string_list_concat(+Strings:list(string), -String:string) is det
 string_list_concat(+Strings:list(string), +Separator:string, +String:string) is semidet
string_list_concat(+Strings:list(string), +Separator:string, -String:string) is det
string_list_concat(-Strings:list(string), +Separator:string, +String:string) is semidet
See also
- atomic_list_concat/3 provides the same functionality for atoms.
 string_postfix(+Original:string, +Postfix:string) is semidet
string_postfix(+Original:string, -Postfix:string) is multi
 string_postfix(+Original:string, +Length:nonneg, +Postfix:string) is semidet
string_postfix(+Original:string, +Length:nonneg, -Postfix:string) is semidet
string_postfix(+Original:string, -Length:nonneg, +Postfix:string) is semidet
string_postfix(+Original:string, -Length:nonneg, -Postfix:string) is multi
Arguments:
Length- is the number of characters in the Postfix string.
Postfix- is the postfix of the Original string that has Length characters.

Fails in case Length is higher than the length of string String.

See also
- atom_postfix/[2,3] provides the same functionality for atoms.
 string_prefix(+Original:string, +Prefix:string) is semidet
string_prefix(+Original:string, -Prefix:string) is multi
 string_prefix(+Original:string, +Length:nonneg, +Prefix:string) is semidet
string_prefix(+Original:string, +Length:nonneg, -Prefix:string) is semidet
string_prefix(+Original:string, -Length:nonneg, +Prefix:string) is semidet
string_prefix(+Original:string, -Length:nonneg, -Prefix:string) is multi
Succeeds if Prefix is a prefix of Original consisting of Length characters.

Fails in case Length exceeds the Original string length.

Arguments:
Length- is the number of characters in the Prefix string.
Prefix- is the prefix of the Original string that has Length characters.
See also
- atom_prefix/[2,3] provides the same functionality for atoms.
 string_strip(+Original:string, +Stripped:string) is semidet
string_strip(+Original:string, -Stripped:string) is det
 string_strip(+Original:string, +Strip:list(char), +Stripped:string) is semidet
string_strip(+Original:string, +Strip:list(char), -Stripped:string) is det
Succeeds if Stripped is a copy of Original where leading and trailing characters in Strip have been removed.

Notice that the order in which the characters in Strip are specified is significant.

The default Strip characters are space, newline and horizontal tab.

Arguments:
Strip- is a list of charaters that will be stripped from the Original string. The default includes: horizontal tab, newline, space, NO-BREAK SPACE (0xa0).
See also
- atom_strip/[2,3] provides the same functionality for atoms.
 string_truncate(+Original:string, +MaxLength:nonneg, +Truncated:string) is semidet
string_truncate(+Original:string, +MaxLength:nonneg, -Truncated:string) is det
See also
- Like string_prefix/3, but the Truncated string is the Original string in case MaxLength exceeds the Original string length.
- atom_truncate/3 provides the same functionality for atoms.
 words_lines(+Words:list(string), +MaxLength:positive_integer, -Lines:list(string)) is det
 words_lines(+Words:list(string), +MaxLength:positive_integer, +Separator:string, -Lines:list(string)) is det
Splits the given list of words into lines that do not exceed MaxLength.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 string_list_concat(Arg1, Arg2, Arg3)
 string_postfix(Arg1, Arg2, Arg3)
 string_prefix(Arg1, Arg2, Arg3)
 string_strip(Arg1, Arg2, Arg3)
 words_lines(Arg1, Arg2, Arg3, Arg4)