If you copy the string (and then destroy the copy), then it is a waste of time to set pos($s)= -1.
It was not an off-by-two error as I consider returning -1 (a 'true' value) for 'not found' to rather suck as an interface, and prefer to avoid returning a false value (0) for 'found at 1st character' so I meant to return the position of the character as asked, not the offset to it.
- tye
In reply to Re^3: The nth occurrence of a character (simple /$c/g)
by tye
in thread The nth occurrence of a character
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |