in reply to Inconsistent behaviour of pos() in s/ ... / ... /

I just did a quick test to confirm the behavior. I don't see it mentioned in the docs for pos, but I guess the reason would be that you're doing a substitution, so the matched text is essentially considered removed from the string at that point. Therefore pos will return the position where the substituted value will be inserted once you've computed it.

Replies are listed 'Best First'.
Re^2: Inconsistent behaviour of pos() in s/ ... / ... /
by johngg (Canon) on May 11, 2006 at 08:36 UTC
    That is an interesting suggestion and it makes perfect sense if it is in fact the designed behaviour. I'm kicking myself for not thinking of it. I couldn't see anything in the documentation either. If this is the way pos() should work it would be nice to have it documented perhaps.

    Thank you for the suggestion.

    Cheers,

    JohnGG