Ok, take your second test case, the one that doesn't work as you expect, and let's walk through it.
What you may want is something like this:
m/\s$pattern(?=\s)/This won't gobble the second space char.
Dave
In reply to Re^3: while =~ consecutive matching problem
by davido
in thread while =~ consecutive matching problem
by p.s
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |