OK, NOTIF can make that a little more efficient --
"x" OP_DUP OP_3 OP_MOD OP_NOTIF 666f6f OP_SWAP OP_1 OP_TOALTSTACK OP_ENDIF OP_5 OP_MOD OP_NOTIF 6261720a OP_FROMALTSTACK OP_1 OP_ADD OP_TOALTSTACK OP_ENDIF OP_FROMALTSTACK OP_1 OP_GREATERTHAN OP_IF OP_CAT OP_ENDIF
666f6f = foo, 6261720a = bar (in hex)
input 03 gives: <Buffer 66 6f 6f>
input 05 gives: <Buffer 62 61 72 0a>
input 07 gives: Nothing on stack
input 0F gives: <Buffer 66 6f 6f 62 61 72 0a>
I guess there's probably other ways to solve this but I like using the alt stack. :-)
OK, NOTIF can make that a little more efficient --
"x" OP_DUP OP_3 OP_MOD OP_NOTIF 666f6f OP_SWAP OP_1 OP_TOALTSTACK OP_ENDIF OP_5 OP_MOD OP_NOTIF 6261720a OP_FROMALTSTACK OP_1 OP_ADD OP_TOALTSTACK OP_ENDIF OP_FROMALTSTACK OP_1 OP_GREATERTHAN OP_IF OP_CAT OP_ENDIF
666f6f = foo, 6261720a = bar (in hex)
input 03 gives: <Buffer 66 6f 6f>
input 05 gives: <Buffer 62 61 72 0a>
input 07 gives: Nothing on stack
input 0F gives: <Buffer 66 6f 6f 62 61 72 0a>
I guess there's probably other ways to solve this but I like using the alt stack. :-)