I have this preg_split to split the text after the punctuation marks.
$content = preg_split('/(?<=[!?.])./', $content);
Problem 1. Ineed a way to split the text but remove punctuation other that question mark.
How can I do this?
Problem 2. Is there a way to capitalize the words which have more than two letters? Right now I use CSS but text-transform: capitalize does it on every word, even 1 letter words and this makes it look funky on the page. This is why I am thinking of using php to do this.
Ty very much,
Hope you can help!
Problem 1:
If you need to split on every pontuation marks but can’t replace on question mark, you need to do it in two steps, because
preg_replacewould replace your question mark too.You should split first then replace(by “”) after that.
Is your regex working as expected ? The first part
(?<=)seems weird according to your problem. I guess just/!\?\\./would do the trick.Problem 2:
I would split your phrases using space then iterate over the resulting array(the words) then checking the size of each word, capitalizing it if it’s size is bigger than 1.