MATL, 17 bytes
Yb94ih'(.*)'h6&XX
Try it on MATL OnlineTry it on MATL Online
How?
Yb
- Split the input at spaces, place the results in a cell array
94
- ASCII code for ^
character
ih
- Get the input (say "frac"), concatenate '^' and the input
'(.*)'h
- Push the string '(.*)'
into the stack, concatenate '^frac' and '(.*)'. So now we have '^frac(.*)
, a regex that matches "frac" at the beginning of the string and captures whatever comes after.
6&XX
- Run regexp matching, with 6&
specifying 'Tokens' mode i.e., the matched capture groups are returned instead of the entire match.
Implicitly output the results.