We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

FeedGrab Plugin and preg_replace

Development and Programming

artcodes's avatar
artcodes
1 posts
18 years ago
artcodes's avatar artcodes

Hi,

I’m working with the feedgrab plugin to pull Twitter posts into ee. I’m having a rather tough time figuring out one simple thing. How to knock the username: off of the post for display when pulled out of exp_weblog_titles.

A normal post looks like: Steve Smith: is going out to see a fight with the guys.

What I’m trying to get rid of is Steve Smith: and leave everything else. I tried the following:

$string = Steve Smith: is going out to see a fight with the guys.;
echo preg_replace("/.*:/", "", $string);

This works fine if there are no more colons in the sentence. Which looks like this: Steve Smith: is going out to: see a fight with the guys. Has this return: see a fight with the guys.

Thanks in advance for any help.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
18 years ago
Lisa Wess's avatar Lisa Wess

Since this is in regards to a third-party plugin, I am going to move it to the Plugins forum for you. =)

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
18 years ago
Andrew Weaver's avatar Andrew Weaver

Something like:

<pre><code>/[^:]*:/<pre><code>

perhaps?

       
Daniel Walton's avatar
Daniel Walton
553 posts
18 years ago
Daniel Walton's avatar Daniel Walton

Or

/.*?:/
       
Edith Frost's avatar
Edith Frost
4 posts
17 years ago
Edith Frost's avatar Edith Frost

In case anybody else searches on this, I found another way to do the same thing, using the Trimmer plugin. I’m removing my name, plus the colon-space, more or less like so:

{exp:weblog:entries weblog="twitter" orderby="date" limit="10"}

{exp:trimmer left="15" right="0"}
{twitter_description}
{/exp:trimmer}

{/exp:weblog:entries}

This only seems to work if I include “right=0”.

(And, I removed my extra code for styling, because it’s ugly and Unclean.)

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.