The second arg to view.find
is actually the start pt
rather than the flags.
Also, view.find_all
has a signature thatās (pattern, flags, replace_format_string, empty_list_reference)
. Itās a somewhat weird/awkward API but the empty_list_reference
will be filled with renderings of the format string for each found region in order.
When it comes to replacing the regions, you donāt have to track offsets manually if you perform the operations in reverse order ( end of document towards beginning). view.find_all
will return the regions in the order they are found so you just need to reverse them. Python has a handy builtin function [reversed](http://docs.python.org/library/functions.html#reversed)
for this.