Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7690741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:27:56+00:00 2026-05-31T20:27:56+00:00

So currently I am trying to add a feature to a userscript I have

  • 0

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

elmTextarea.value   = opening + elmTextarea.value + closing;

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

[quote='name' pid='20784507' dateline='1331755619'])

but could also be just [quote]

So here is a quick example so you can better understand

if elmTextarea is

blahbla
[quote='name' pid='20784507' dateline='1331755619']
some more text
[/quote]

here is some more

[quote='name' pid='20523454507' dateline='1335435619']
some more text in here
[/quote]

and finally this text

it would become

opening + blahbla + closing
[quote='name' pid='20784507' dateline='1331755619']
some more text
[/quote]

opening + here is some more + closing

[quote='name' pid='20523454507' dateline='1335435619']
some more text in here
[/quote]

opening + and finally this text + closing

So I have an idea as to how this would work, and here is my attempted implementation

var openingquote = closing + "[quote";
var closingquote = "[/quote]" + opening;
elmTextarea.value   = opening + elmTextarea.value + closing;
elmTextarea.value = elmTextarea.value.replace(/[quote/gim, openingquote);
elmTextarea.value = elmTextarea.value.replace(/[\/quote]/gim, closingquote);

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:27:58+00:00Added an answer on May 31, 2026 at 8:27 pm

    Square brackets have a special meaning in a Regular expression. These should also be escaped:

    elmTextarea.value = elmTextarea.value.replace(/\[quote/gim, openingquote);
    elmTextarea.value = elmTextarea.value.replace(/\[\/quote]/gim, closingquote);
    //                                             ^ Escape [ using \[
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to get into the Java EE development with the Spring framework.
I´m currently trying to add the feature that is discussed here: http://blog.bmn.name/2008/03/jquery-fadeinfadeout-ie-cleartype-glitch/ A glitch
I'm trying to add a feature into my app that allows the user to
I am currently trying to add some parsing methods to a controller method in
i'm currently trying to do a little upload-feature for some of my clients, so
I'm currently trying to add an MSChart to a partial view in ASP.NET MVC
I am trying to get the program to call up the current date, add
I'm currently trying to read in an XML file, make some minor changes (alter
I'm currently trying to debug a customer's issue with an FTP upload feature in
I am trying to render video via the NDK, to add some features that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.