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

  • Home
  • SEARCH
  • 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 7089763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:57:43+00:00 2026-05-28T07:57:43+00:00

I am looking to take a <div> and filter the contents inter a certain

  • 0

I am looking to take a <div> and filter the contents inter a certain format, similar to BBCode. This is the format for each instance.

<blockquote><dl><dt>Username</dt><dd><a class="viewpostbutton" href="http://POSTURL"><img src="http://IMAGEURL" alt="View Original Post" id="vieworiginalbutton"></a></dd></dl><div>QUOTETEXT</div></blockquote>
<blockquote><dl><dt>Username</dt><dd><a class="viewpostbutton" href="http://POSTURL"><img src="http://IMAGEURL" alt="View Original Post" id="vieworiginalbutton"></a></dd></dl><div>QUOTETEXT</div></blockquote>
<blockquote><dl><dt>Username</dt><dd><a class="viewpostbutton" href="http://POSTURL"><img src="http://IMAGEURL" alt="View Original Post" id="vieworiginalbutton"></a></dd></dl><div>QUOTETEXT</div></blockquote>

I wish to filter each occurrence of several strings to format the code like this:

[quote=Username,http://POSTURL]QUOTETEXT[/quote%5D

I have tried to get this using regexp in jQuery, like so:

$("selector").replace(/<blockquote><dl><dt>/g,"[quote=")
$("selector").replace(/<\/dt><dd>/g,",")

And so on. However, the .replace functions fail after the first replace string; the following .replace functions fail regardless of content. This also fails.

$("selector").replace(/</g,"[")
$("selector").replace(/>/g,"]")

So the code becomes [tag> instead of [tag].

For the POSTURL, I am using

$("selector").each(function() {
var printpost = $(this).find('a.viewpostbutton').attr('href');
});

Which seems to work well enough until I try to replace with it; I get the same problem of it just not working.

Why does it not work after the first replace function? What is the correct syntax or how would you complete my task? What should I do?

  • 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-28T07:57:44+00:00Added an answer on May 28, 2026 at 7:57 am

    I’m not sure how you are trying to use that code… there is no replace method in jQuery.

    You can’t replace parts of HTML tags and put the code back in the elements, as partially replaced tags is not valid HTML code. Get the code, make all replacements, then put the code back.

    Loop through the elements, and use pattern matching in the regular expression to get the parts of the code that you want:

    $("selector").each(function(){
      $(this).html(
        $(this).html().replace(
          /<blockquote><dl><dt>(.*?)<\/dt><dd><a class="viewpostbutton" href="(.*?)"><img src="http://IMAGEURL" alt="View Original Post" id="vieworiginalbutton"><\/a><\/dd><\/dl><div>(.*?)<\/div><\/blockquote>/g,
          '[quote=$1,$2]$3[/quote]'
        )
      );
    });
    

    Alternatively, use jQuery to locate the blockquote elements, extract the data from them, and create new content. This is more resilient against browser differences and variations in the markup:

    $("selector blockquote").replaceWith(function(){
      var text = $('dt', this).text();
      var href = $('a', this).attr("href");
      var desc = $('div', this).text();
      return "[quote="+text+","+href+"]"+desc+"[/quote]";
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to take a map<char, vector<char> > and generate each possible map<char,
I am looking for a tool which will take an XML instance document and
As illustrated in this jsfiddle: http://jsfiddle.net/qrbhb/ If you take this markup: <div>There should be
I'm looking to take the results of a report run (a PDF file from
I am looking to take a PDF and extract any text from it. I
I'm looking to take the result of a SQL Server stored procedure and transform
Looking for a bit of advice on where to take a current webapp which
Im looking for a script that will take OData feed and download some .wmv
I'm looking for the best way to take a simple input: echo -n Enter
I'm looking for an algorithm which can take two sets of integers (both positive

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.