Thanks for your reply. I have updated the OP with some sample input, which is, as you see, rather simple. I realised that the capturing the $ and then removing it is a bit silly, but when I moved the $ out of the capturing brackets, the match failed, so obvioulsy I have to escape the $ in some other way. You are right of course about not then needing two variables, one with the $ and one without.
"It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."