1:- module(bc_string, [
    2    bc_string_replace/4 % +Atomic, +Atomic, +Atomic, -String
    3]).    4
    5/* <module> String helpers */
    6
    7:- use_module(library(error)).
 bc_string_replace(+In, +Search, +Replacement, -Out) is det
Helper to replace all occurences in given string. Out is string.
   14bc_string_replace(In, Search, Replacement, Out):-
   15    must_be(atomic, In),
   16    must_be(atomic, Search),
   17    must_be(atomic, Replacement),
   18    atom_string(In, InString),
   19    atom_string(Search, SearchString),
   20    atom_string(Replacement, ReplacementString),
   21    atom_string(InAtom, InString),
   22    atom_string(SearchAtom, SearchString),
   23    atomic_list_concat(Tokens, SearchAtom, InAtom),
   24    atomics_to_string(Tokens, ReplacementString, Out)