What RegEx would replace a single 'm' letter with (e.g.) a number, assuming that 'm' must be single letter ('m' in 'm.n' or 'L m' should be replaced, but 'm' in 'mind' or '1m' must not) and may appear in beginning of string or at the end ?
Examples:
'mind'.replace(exp,'7') => 'mind'
'm-ind'.replace(exp,'7') => '7-ind'
'-m-ind'.replace(exp,'7') => '-7-ind'
(exp must be identical in all above examples)
Not sure I understand, but this will only match letter
mwhich is not part of a word:\b(m)\bEDIT:
At the suggestion of Qtax, you can remove the capturing group if you only want to replace
mand nothing more:\bm\b