Hey guys, I hope I am able to explain this as easy as possible. Basically I am compiling a list and to do so I need to remove a load of text after a certain trigger word.
Example of what I am trying to achieve is here
Say I have just pasted a bunch of text in my text box, I want everything removed apart from the first username.
And example would be…
r-u-f-f-i-a-n reblogged this from youaref0rsaken
youaref0rsaken reblogged this from loveeoutoflust
loveeoutoflust reblogged this from yourwatchfuleye
Which I would want to turn in to
r-u-f-f-i-a-n
youaref0rsaken
loveeoutoflust
With using a textbox with the input, a button and a textbox which would display the output. I have tried doing this using jquery and php preg_replace but cannot get it to function correctly.
Is anyone able to help me with this?
look into javascripts replace funciton
as an example check out this fiddle using the code below http://jsfiddle.net/vwhCx/
note: if the concept of a regexp is new to you the only thing to know here: /reblogged this from/g is that the //g means globeably, or more than one match.
UPDATE
based on your comment I have altered my code to work on a text area
use this
new live example: http://jsfiddle.net/K3LZU/
LAST EDIT
if you are trying to display it as a list, or newlines try str.replace(/reblogged this from/g, ‘\n’) the \n indicating a newline