Regex to get rid of everything past the first sentence in a string in php
- by andufo
I need to get rid of everything after the first dot (if there is more than 1 sentence), but at the same time, cases like e.g. have to be omited.
Some line e.g., when people do something. Extra content.
Some line (some parenthesis). Extra content.
I need to get rid of the "Extra content.". The returning value should be:
Some line e.g., when people do something.
Some line (some parenthesis).
So far I've come with this regex taken from other threads, but it only finds the dots and split the string into an array.
preg_replace('/(?<!\.)\.(?!(\s|$|\,|\w\.))/','',$text);
Any ideas? Thanks.