PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Sep 20, 2017 2:50 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Feb 12, 2017 6:14 pm 
Offline
Forum Newbie

Joined: Sun Feb 12, 2017 6:09 pm
Posts: 1
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

Syntax: [ Download ] [ Hide ]
$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

Syntax: [ Download ] [ Hide ]
St


Thank you


Top
 Profile  
 
PostPosted: Sun Feb 12, 2017 9:15 pm 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6347
Location: Montreal, Canada
What about a negative lookahead?

http://rubular.com/r/NkzLPlN1PA

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group