Dear friends, My sir, gave me this following lines.... " Your beloved will bring happiness and success to you,,,, your friends will support you in tough situations of life. Time to spend money on your homely accommodations..... Avoid being volunteer to overspend otherwise you will loose a lot " Hear are the following mistakes.. > In the above lines, if you see you,,,,, hear we have to get a single comma not 4 commas > And accommodations....., hear we have to get single fulstop, not ....., > And at the end of the para if there is no fulstop.., we must get one fulstop ( . ), Once we run the program we have to get good paragraph with out anny errors...!! please help me or any ideas please.
$text = trim($text); $text = preg_replace('~([\.,])\1+~', '$1', $text); if (substr($text, -1) !== '.') $text .= '.'; PHP: ... untested, but should work. Although, using 3 periods in a row is not incorrect grammar. Removing them might ruin the context of the sentence. And what if the last sentence ends with an exclamation mark?
Looks like some kind of astrology script that throws out random lines, as @nico_swd's has said, removing them could make the sentence even more cryptic I don't know if that's a good or bad idea Myself I would start to edit the sentences, it might be a long and boring task, so maybe 50-100 a day, you will finish editing in a few days, problem solved.