This string predicate removes part of a string. The first argument is the string to delete a part from. The second argument is the position to start deleting from, the first character in the string is position 1. The third argument is the number of characters to delete. If any or both of the number arguments is equal to or smaller than 0 an evaluation_error(not_positive, A) is thrown. The predicate fails if a character must be deleted that does not exist.
see also: &/2 expand_sq/1 insert/3 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 delete("ab", 1, 2). | X="" (all the characters in the string were removed) |
| X is_string delete("abcde", 1, 2). | X="cde" (all the characters in the string were removed) |
| X is_string delete("abc", 2, 3). | fails because the string is too short |
| X is_string delete("abc", 0, 3). | evaluation_error(not_positive, 0) |
| 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 |