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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:05:38+00:00 2026-06-11T18:05:38+00:00

I am getting stuck. Perhaps there is a better way with the regex (like

  • 0

I am getting stuck. Perhaps there is a better way with the regex (like to hear your thoughts).

AS a ONE-OFF the following works if I am just subbing in one thing, say -link-.

var testHtmlStr = '<tr>' +
                '<td class="eve"><div class="pad" style="overflow:hidden;">' +
                  '<a href="#" class="pic"><img height="50" width="80" title="{%desc%}" alt="{%desc%}" src="{%image%}"></a>' +
                  '<div class="sum"><a href="{%link%}" class="url">{%name%}</a></div>' +
                  '{%star_rating_html%}' +
                  '<a href="#" class="gray">{%eventC%}</a>' +
                  '<span class="block">{%evenC%}</span>' +
                '</div></td>' +
                '<td class="mor"><div class="pad"><a class="mor" href="{%link%}">{%linkName%}</a>' +
                '</div></td>' +
              '</tr>';
var ss = 'link';
var syntax = new RegExp('(^|.|\r|\n)(\{%\s*(' + ss + ')\s*%\})',"gi");

 alert(testHtmlStr.replace(syntax, '$1TESTESTESTESTS'));

The following is my code and it DOES NOT WORK. I can’t figure out why. Same regex, same html template pattern. Also, my .each reiterates thru the string, but it seems after every reiteration the string returns to its unmodified state. Basically, whatever is the html string like so {%somehashkey%}, I want it to be replaced with the corresponding hash value.
I figured my code would work, can’t figure out what is wrong. Something is out of wack, I know that. I can’t hunt it down. Your thoughts?

(function($){
var testHTML2 = '<tr>' +
                '<td class="eve"><div class="pad" style="overflow:hidden;">' +
                  '<a href="#" class="pic"><img height="50" width="80" title="{%desc%}" alt="{%desc%}" src="{%image%}"></a>' +
                  '<div class="sum"><a href="{%link%}" class="url">{%name%}</a></div>' +
                  '{%rating%}' +
                  '<a href="#" class="gray">{%eventC%}</a>' +
                  '<span class="block">{%evenC%}</span>' +
                '</div></td>' +
                '<td class="mor"><div class="pad"><a class="mor" href="{%link%}">{%linkName%}</a>' +
                '</div></td>' +
              '</tr>';

var type = "yahoo";
var disp = {};
disp.eventC = '5';
disp.rating = "<div>rating here</div>";
switch (type) {
case 'yahoo':
    disp.link = 'http://www.yahoo.com';
    disp.image = 'SOMe IMAGE' ;
    disp.name = "VENICE BEACH";
    disp.desc = 'MORE INFO&nbsp;';
    disp.linkName = 'YAHOO';
break;
default:
    disp.link = 'http://www.google.com';
    disp.image = 'Some IMAGE';
    disp.name = "BABY BABY";
    disp.desc = 'MORE INFO&nbsp;YOYOYO';
    disp.linkName = 'GOOGLE';
}

$.each( disp, function(t, num){
var syntax = new RegExp('(^|.|\r|\n)(\{%\s*(' + t + ')\s*%\})',"gi");
testHTML2.replace(syntax, num)
});
alert(testHTML2);
})(jQuery);
  • 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-11T18:05:39+00:00Added an answer on June 11, 2026 at 6:05 pm

    You are not assigning new value to testHTML2.

    testHTML2 = testHTML2.replace(syntax, num)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel like I'm asking a lot of questions, but I keep getting stuck.
Is there any reason why this loop is getting stuck? I can't quite get
I'm trying to implement the following code in Ruby and getting stuck on it.
I'm trying to write a bit mod rewrite regex and getting stuck. I want
What is the best way of getting some of the stack trace info, perhaps
Getting stuck on chapter 8: Type as many words as we want One word
I'm having an issue with scanf() getting stuck, and the only way to continue
I am getting stuck in a page,where I'm using selectbox & checkbox,and they will
I am new to rails and getting stuck a lot trying to develop my
I have a function (bobB) that seems to be getting stuck in a while

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.