Seemingly a relatively simple problem, I can't seem to find a solution...
I want to build a pattern that will match any symbol whose name starts with V, and is elevated at any power. Something on the line of:
MatchQ[#1, (V1 | V2 | V3)^_.] & /@ {V1, V1^2, V2}
That returns true for each of the entries. I haven't found a way to put constrains on the symbol name, if not by using SymbolName[]
and working with string patterns:
MatchQ[#1, (_)?(StringMatchQ[SymbolName[#1], "V" ~~ __] &)^_.] & /@ {V1, V1^2, V2}
However, it doesn't look exactly beautiful... (only to me?) :-) Is there a more compact and elegant way of putting constraints on a symbol name? I'm feeling like I'm totally missing a very obvious function that would do that...