in reply to Re^4: Bizarreness in ?PATTERN? and g
in thread Bizarreness in ?PATTERN? and g

The intent of the interaction between /g and pos() is to allow you to build parsers that "consume" a string. You read the first part, and if that matches, you read the second part, and if that fails, you try an alternative for the second part, and so on.

Check out the Mastering Regular Expressions book for some ideas on how to keep this in mind, and take advantage of it for parsing tasks.

--
[ e d @ h a l l e y . c c ]