Thanks Martin. You are right that changing \ip to \p seems to help - if all I want is verse 1. But now the \ref in the module expands to include not just verse 1, but all the entire content of \esb as well. That isn't really what I had in mind. I just want verse 1 without \esb. (Interestingly, it skips over \s which is between \esb and \v 1, so that shows that the algorithm CAN skip extraneous stuff.)
But if I specify verse 2 or any subsequent verse, the program fails. It only works - sort of - with verse 1. So it seems there is still some kind of issue here. Again, if I remove the \esb material, it all works fine. Sorry for the trouble!
NB: We have 600+ pages of Bible school materials in XXA-XXF which have hundreds (a thousand?) hard-coded scripture passages from ancient versions of our Biblical text. As we come down to the wire to publish the NT after all these years, the module capabilities would be a really nice alternative to copying and pasting all those passages manually - probably not for the last time.