Analogously to numbers, there are several predefined operations for strings. These built-in predicates all have a fixed arity and (as for all built-in predicates) must not be used in the head of rule.
is true, if <arg> is a string.
_concat(<string 1> , <string 2> , <string 3>)
succeeds if <string 3> is the concatenation of <string 1> and <string 2>, e.g.,
returns the binding ?X = "ab" whereas
leads to ?Y = "b"
cuts the last n characters from <string>
breaks the string into tokens at the delimiters
breaks the string into maximal n tokens at the delimiter
transforms all characters into lower characters
transforms all characters into upper characters
Regular expressions may be used to search in strings with this predicate. The first parameter defines the search string as aregular expression. Regular expressions are defined as PERL regular expressions. The second parameter defines the string to search in, and the last parameter defines the resulting string, i.e. the region that matched the pattern, e.g.
The query "search for all married people with a "p" or "t" in their name":
?- married(?X) and _regexp("[pt]",?X,?Y).
?X = "peter", ?Y = "p"
?X = "peter", ?Y = "t"
?X = "tom", ?Y="t"