I’m playing with using Regex to modify Twitter posts. I’m currently attempting to trim each tweet up to (but not including) the last occurrence of a retweet string (example: RT @Sam:). I’m already filtering my feed so that only tweets containing at least one retweet string are kept. The regex I’m using to do this is RT @[A-Za-z0-9_]+:.
So, my question is, simply, how can I trim (cut off) each string up to, but not including, the last occurrence of RT @[A-Za-z0-9_]+:?
So, for example:
RT @Sam: Look what Susan said. RT @Susan: Hello!
should end up as:
RT @Susan: Hello!
(In case it’s helpful, I’m using Yahoo! Pipes for this experiment.)
Use regex
(RT @(?!.*@).+:.+)to find the match…Negative lookahead
(?!.*@)is a condition that says there is no@beyond this point.Test it here.