greasemonkey userscript injects variables within another variable

FlashSoft

New Member
So currently I am trying to add a feature to a userscript I have made.Currently the userscript will get some text into a variable. Now there are also have 2 vars, that currently are for adding text to the begenning and end of the text in the first var. Here is a code sample to make you better understand what it is currently doing\[code\]elmTextarea.value = http://stackoverflow.com/questions/9713404/opening + elmTextarea.value + closing;\[/code\]Where elmTextarea is the string that the userscript got and opening and closing are the things I put in the beginning and end of it.Now, what I want to happen is that if the variable elmTextarea includes any [quote*]blahblahblah[/quote] it essentially will exclude those areas(not the star could be anything, it is in the format\[code\]
name said:
)\[/code\]but could also be just
So here is a quick example so you can better understandif elmTextarea is\[code\]blahbla
name said:
some more text
here is some more
name said:
some more text in here
and finally this text\[/code\]it would become\[code\]opening + blahbla + closing
name said:
some more text
opening + here is some more + closing
name said:
some more text in here
opening + and finally this text + closing\[/code\]So I have an idea as to how this would work, and here is my attempted implementation\[code\]var openingquote = closing + "[quote";var closingquote = "
" + opening;elmTextarea.value = http://stackoverflow.com/questions/9713404/opening + elmTextarea.value + closing;elmTextarea.value = elmTextarea.value.replace(/[quote/gim, openingquote);elmTextarea.value = elmTextarea.value.replace(/
/gim, closingquote);\[/code\]but adding these lines into my code makes my whole script not work. Any ideas as to why this does not work and how to fix it.
 
Top