Regular expressions look awfully complicated until you look close enough...
I will explain the pattern here:
- $ is a special character so we need to "escape" it -> \$
- Then we want to catch all characters that are not # -> ([^#]+) note that the parenthesis define a group (group number 1).
- The # character.
- All characters that are not * -> ([^*]+) note that we do not need to escape special characters in a negation class.
- The * character.