"Remove all characters after the last period" can also be re-stated as, "keep all characters up to a period," relying upon the default 'greedy' behavior to slurp as many characters as it can. Keep what the regular-expression keeps (if it kept anything at all, otherwise leave the string unchanged as it contains no period at all).