Using replace
, how do you replace space period with just period anywhere within text?
Currently I could only figure out searching for space and replacing it with a period, but I need for it to look for a pattern of space + period. BTW, this pattern is random, so some sentences appear correctly, without the excess space before the period.
Example:
Lorem ipsum dolor sit amet, consectetur adipiscing elit . Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae elementum curabitur .
So far I have the following, but this is wrong as it replaces all spaces with periods.
cleanData(str) {
return str.replace(/s/g, '.');
}
question from:
https://stackoverflow.com/questions/65861822/js-use-replace-to-replace-space-period-with-period 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…