Need help with preg replace

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
Forum Newbie
Posts: 1
Joined: Sun Feb 12, 2017 5:09 pm

Need help with preg replace

Post 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


Thank you
User avatar
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Need help with preg replace

Post by Celauran »

What about a negative lookahead?
Post Reply