in reply to Can't understand why /g does not work as I expect

To see what is going on, use very short sample input and
use re 'debug';