I'm trying to understand Mathematica's pattern matching in strings, but I have some doubts.
99% of the time I need to a) check if a match occurs and b) retrieve the matched patterns.
I come from perl, where it is easy to do both in two lines:
"big bad wolf =~ / (.*) /; print"$1\n"
In Mathematica is it possible to do it with just one function call? For now I'm able to do
a = "big bad wolf" StringMatchQ[a, RegularExpression["big .* wolf"]]
StringCases[a, RegularExpression[" (.*) "] -> "$1"]
As a 2nd question -- how can I retrieve more than one pattern, e.g. from this call:
StringCases[a, RegularExpression["(.*) .* (.*)"]