Page 1 of 1

Need help with preg replace

Posted: Sun Feb 12, 2017 5:14 pm
by MickDDD
Hi All, thanks for having me on your forums...

I have a quite in depth script that uses allot of PREG replace to output what I need.

The only problem is that i need some stop words (omitted words) from the preg replace but I dont know how to do it.

This is the code

Code: Select all

$dataa = preg_replace('/(\b.{1,2}\s)/',',',$dataa);
it basically removes all 2 letter and smaller words from my string.

But I need it to keep the word

[text]St[/text]

Thank you

Re: Need help with preg replace

Posted: Sun Feb 12, 2017 8:15 pm
by Celauran
What about a negative lookahead?

http://rubular.com/r/NkzLPlN1PA