Let's say there's a textarea text with following content:
On date at 3:16 PM, Sir Voldemort wrote:
> Sweet Harry!
> Let's see what's gonna happen.
>
>
> On date at 3:11 PM, wrote:
>
>> Awesome!
>>
>>
>> --
>> Random: string or sentence here, it doesn't matter
>> Another random line with e.g. a URL: http://www.jkrowling.com/
>>
>
>
>
> --
> **********************************************
> ABCABCCAB
> **********************************************
>
Quote
“Efe iska?”
--
Random2-1
Random2-2
**********************************************
ABCABCABC
**********************************************
Now if there occurs a line with just two dashes -- (and none, one or more > in front) in it, this line and the following two lines should get deleted.
Like that:
On date at 3:16 PM, Sir Voldemort wrote:
> Sweet Harry!
> Let's see what's gonna happen.
>
>
> On date at 3:11 PM, wrote:
>
>> Awesome!
>>
>>
>>
>
>
>
> **********************************************
>
Quote
“Efe iska?”
**********************************************
ABCABCABC
**********************************************
I already started with the following code to detect the previous line of -- to start a another substr but there is more sure a way more simple regexp solution for it?
var msg = document.getElementById('msg'); // wrapped textarea around the text with ID msg
msg.value = msg.value.substr(0, msg.value.substr(0, msg.value.match('--\n').index).lastIndexOf('\n'))
> --,> *************and> ABCABCCABbeing deleted? They follow the pattern you indicate.