Things like \S in your "pattern" are being interpreted as regular expressions. You should quotemeta before using the string as a pattern. This is also the same as doing /\Q$pattern/ for a pattern.
If you're just matching literal strings, though, index would be a good way to go.
In reply to Re: Pattern matching and setting the match to a variable
by kyle
in thread Pattern matching and setting the match to a variable
by mrbbq
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |