How to make insert text an atomic range

I find an example about atomic ranges and i notice this example implemented by using regexp to match text.

but i want to make insert text to be an atomic range, and not use regexp,because i don’t kown the format of the insert text

view.state.update({changes: {from, to, insert: “xxx”}})