This string predicate inserts a string into another string. The first argument is the destination string, the second argument is the string to insert and the third argument is the position where the substring is inserted. The index of the first character in a string is 1, to insert in front of the first character use the value 1. If the third argument is 0 or a negative number then an evaluation_error(not_positive, A) exception is thrown. If the index value is larger than the length of the string the predicate fails.
see also: &/2 delete/3 expand_sq/1 is/2 replace/3 substring/3 string_list/2 to_lower/1 to_prolog/1 to_string/1 to_string/2 to_upper/1 trim/1 triml/1 trimr/1 working with strings
| Examples | |
| X is_string insert("a", "bc", 1). | X="bca" |
| X is_string insert("a", "bc", 2). | X="abc" |
| X is_string insert("a", "bc", 3). | fails |
| Exceptions | |
| argument is an empty variable | an instantiation_error exception is thrown |
| the first argument is smaller than 1 | an evaluation_error(not_positive, 0) exception is thrown |