trim( +term )

This built-in string predicate removes the leading and trailing whitespace characters from the argument string. To just remove the leading whitespace use triml/1 and to remove trailing whitespaces there is the predicate trimr/1.

see also: &/2 delete/3 expand_sq/1insert/3 is/2 substring/3 string_list/2 to_lower/1 to_string/2 to_upper/1 triml/1 trimr/1 working with strings

Examples
X is_string trim('  abcd   '). variable X is unified with the string 'abcd'
X is_string trim(' a b f '). variable X is unified with the string 'a b f'

 

Exceptions
The parameter is an empty variable an instantiation_error exception is thrown

 

 

info@trinc-prolog.com