BandonRandon Posted September 23, 2008 Share Posted September 23, 2008 Hello, So I've been trying to create a Lifestream http://blog.bandonrandon.com/lifestream for myself. I have found the feed url to my facebook mini feed but i feel that facebook gives away to much information for a public feed. A friend told me to use yahoo pipes http://pipes.yahoo.com/pipes/ which will let me modify the feeds content. Well it works great but I have a unique regex problem for someone. The feed will output data like this: # FirstName LastName accepted your friend request. # FirstName LastName wrote on your Wall. # FirstName LastName wrote on your Wall. and so on and so fourth. I would like this to read # Someone accepted My Name's friend request. # Someone wrote on My Name's Wall. # Someone wrote on My Name's Wall. one of the pipes operators is regex where i can replace variables. I am still very new to regex and am getting better but still need to be coached on it. Thanks, Brandon Quote Link to comment Share on other sites More sharing options...
effigy Posted September 23, 2008 Share Posted September 23, 2008 Assuming they use PCRE: <pre> <?php $data = <<<DATA # FirstName LastName accepted your friend request. # FirstName LastName wrote on your Wall. # FirstName LastName wrote on your Wall. DATA; echo preg_replace('/^(.+?)(?=accepted|wrote)/m', 'Someone ', $data); ?> </pre> You can use str_replace to exchange "your" with your name, since it should be static Quote Link to comment Share on other sites More sharing options...
BandonRandon Posted September 23, 2008 Author Share Posted September 23, 2008 Thanks for the help, I was able to get the static field corrected but wasn't able to get the first name/ last name corrected. Any help would be great! Quote Link to comment Share on other sites More sharing options...
effigy Posted September 23, 2008 Share Posted September 23, 2008 According to the vague docs, try this: replace [ ^(.+?)(?=accepted|wrote) ] with [ Someone ] Quote Link to comment Share on other sites More sharing options...
BandonRandon Posted September 23, 2008 Author Share Posted September 23, 2008 Thank you that worked! I agree that the pipes documentation isn't the best. It's actually a pretty cool thing though. Brandon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.