Can someone help me figure something about regexes?
Say I have something like:
$str = "+ +z a"
I want to match words up to a whitespace or end of string. They may be preceeded with a +, but I do not want to match + alone. A word consists of any char except + and whitespace.
So I wanted to match +z (first valid word in string).
I tried this:
/[+]*\S+/
It matched "+". Not what I need.
I tried this:
/[+]*[+\s]+/
I matched "+z".
It is like \S is a valid match even if it does not match anything. Why is that? Is there a way to change this behavior?
Thanks!