
split_string(+String, +SepChars, +PadChars, -SubStrings)

   Decompose String into SubStrings according to separators SepChars and
padding characters PadChars.



Arguments
   String              A string.
   SepChars            A string.
   PadChars            A string.
   SubStrings          A variable or list.

Type
   Strings and Atoms

Description
   The string String is decomposed into sub-strings which are returned
   as a list of strings SubStrings.  Every character occurring in
   SepChars is considered a separator, and every character occurring
   in PadChars is considered a padding character.


   The string String is split at the separators, and any padding
   characters around the resulting sub-strings are removed. Neither
   the separators nor the padding characters occur in SubStrings.


   Characters that occur both in SepChars and PadChars are considered
   separators, but such that a sequence of them is considered to be
   only one separator. Moreover, when they occur at the beginning or
   end of the string, they are ignored, ie. treated like padding.


   The predicate can also be used to trim leading and trailing padding
   from a string by giving an empty separator string.




Modes and Determinism
   split_string(+, +, +, -) is det

Exceptions
     4 --- String, SepChars or PadChars is not instantiated.
     5 --- String, SepChars or PadChars is not a string.
     5 --- List is neither an string nor a variable.

Examples
   
     % split at every /
     [eclipse]: split_string("/usr/local/eclipse", "/", "", L).
     L = ["", "usr", "local", "eclipse"]
     yes.

     % split at every sequence of /
     [eclipse]: split_string("/usr/local//eclipse/", "/", "/", L).
     L = ["usr", "local", "eclipse"]
     yes.

     % split and strip padding
     [eclipse 4]: split_string(" comma, separated , data items ",
                                                        ",", " \t", L).
     L = ["comma", "separated", "data items"]
     yes.

     % just strip padding
     [eclipse]: split_string("   Hello world...", "", " .", L).
     L = ["Hello world"]
     yes.






See Also
   atom_string / 2, atomics_to_string / 2, atomics_to_string / 3, number_string / 2, read_string / 3, read_string / 5, read_token / 2, read_token / 3, term_string / 2, library(regex)
