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 8805363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:50:49+00:00 2026-06-14T01:50:49+00:00

I have more DIVs like this: <span class=date>Fri November 9, 2012</span> All these are

  • 0

I have more DIVs like this:

<span class="date">Fri November 9, 2012</span>

All these are in a var.
Example:

var = '
...<span class="date">Fri November 9, 2012</span>...
...<span class="date">Fri November 9, 2012</span>...
';

I try to replace each date with a image that contain this date.

I have this line but this didn’t works:

ver = ver.replace(/<span class="date">(.*)<\/span>/g,'<span class="date"><img src="generateLink.php?nr='+encodeURIComponent($1)+'" /></span>');

My question is: I can’t use encodeURIComponent in regex?

  • 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-06-14T01:50:51+00:00Added an answer on June 14, 2026 at 1:50 am

    Use replace with callback function

    ver = ver.replace(/<span class="date">([^<]*)<\/span>/g,
    function($0,$1) {
       return '<span class="date"><img src="generateLink.php?nr='+encodeURIComponent($1)+'"   /></span>'
    });
    

    And can be more simple

    ver = ver.replace(/(<span class="date">)([^<]*)(<\/span>)/g,
    function($0,$1,$2,$3) {
        return  $1+'<img src="generateLink.php?nr='+encodeURIComponent($2)+'" />'+$3
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The HTML looks something like this: <li class=divider> <div> ...(maybe more divs)... <div class=content>
I have multiple divs like this: <div class=small></div> <div class=small></div> <div class=small></div> <div class=small></div>
I have a page with multiples divs like this <div class=bigbox> <a href=http://www.somestuff.com>some stuff</a>
I have a list of DIVs, like this : <div id=list> <div class=classA classB
I have a file like <div> <div class=abc> <div> <!--some more divs inside--> </div>
My issue is that I have two (or more) divs of the same class,
I have more or less been able to understand and implement all these concepts
Easy question, it is valid to have overlapping spans in html? Example: <span id=1>This
i have 4 divs inside of a div like this: <div id=Wrapper> <div id=CoreSideBar><!--
basically I have 4 images with divs set up like this: <div id=selector> <div

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.