WhatMShallTweMdoT
/^.+?(?=M)/g
(.+?) makes the regex non-greedy.
(?=M) is the condition. This is a postive lookahead assertion.
What is matched is: What
For more information:
https://stackoverflow.com/questions/7124778/how-to-match-anything-up-until-this-sequence-of-characters-in-a-regular-expres
For the regex engine:
http://regexr.com