A.49 library(strings): String utilities
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • The SWI-Prolog library
        • library(strings): String utilities
          • string/4
          • interpolate_string/4
          • string_lines/2
          • dedent_lines/3
          • indent_lines/3
          • indent_lines/4
    • Packages
Availability::- use_module(library(strings)).(can be autoloaded)
Source[det]string_lines(?String, ?Lines)
True when String represents Lines. This follows the normal text convention that a line is defined as a possible empty string followed by a newline character ("\n"). E.g.
?- string_lines("a\nb\n", L).
L = ["a", "b"].
?- string_lines(S, ["a", "b"]).
S = "a\nb\n".

This predicate is a true relation if both arguments are in canonical form, i.e. all text is represented as strings and the first argument ends with a newline. The implementation tolerates non-canonical input: other types than strings are accepted and String does not need to end with a newline.

See also
split_string/4. Using split_string(String, "\n", "", Lines) on a string that ends in a newline adds an additional empty string compared to string_lines/2.