One way to circumvent the problem is to use atom_codes/2 to first convert the list into an atom and then use that atom repeatedly in the match operations. One problem here might be the aforementioned overflow of the atom table. So, if this is a concern, the following predicate (which always succeeds) can help:
re_charlist_to_string(+ListOfCharacters, -String)This predicate converts lists of characters into uninterned strings, which can be used without the fear of atom table overflow:
| ?- re_charlist_to_string("abcdefg",L). L = abcdefgThe resulting string can be passed to re_match/5, re_substitute/5, and re_substring/4 for further processing.
Note, however: you cannot call re_charlist_to_string before you finished working with the string generated by the previous call: all calls to this function use the same static buffer to hold the output string, so each subsequent call to re_charlist_to_string will override the previously generated strings.