I want replace M
in the following text with April
Sample Text:
dddd yy aM5 May May SUM MMMM 56 MM M
Expected result:
dddd yy aApril5 May Mars SUM MMMM 56 MM April
Really i want ignore replacment when:
M
is start ofMay
andMars
M
is between someM
Like:MMMM
orMM
orMMM
M
is end ofSUM
I tried the following code but it dose not exclude special words from replacement:
text.replace(/[^May|Mars|MMMM|MM|MMM|SUM]M/g,"April")
// Incorrect result>> dddd yy aM5AprilayAprilay SUMAprilMMM 56AprilMApril