I want to match either whitespace or beginning or end of string. The obvious way to do this is with assertions, or something like (\S|^)
. I'm wondering if there isn't some simpler way to do it.
The motivation is that I have a string which looks like:
alpha="first" beta="second" gamma="third"
So to see if beta is there, and has the correct value, I could match it with something like
m/\sbeta="second"\s/, but this loses at the beginning and end of the string. What I'd like is something like \b which also works as expected at the ends. I'd like something simpler because colleagues that don't know Perl need to write simple regex's for testing with my interpreter.
OK, folks, thanks for your contributions. I now know that I was not missing anything obvious, which was my chief aim.