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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:53:56+00:00 2026-05-18T01:53:56+00:00

This is a more specific question of my other question . I need to

  • 0

This is a more specific question of my other question.

I need to extract parts from this table row..

<tr><td colspan="7"><a href="http://link/index.php?view=page&id=2961" target="_blank" title="title">atext1 atext2</a> - stuff 2 - <img src="img/icon_1.gif" class="icon" title="icon1" />12 - <img src="img/icon_2.gif" class="icon" title="icon2" />4 - <span title="long title"><img src="img/icon_3.gif" class="icon" /> stuff 5 </span></td></tr>

..so I end up with an array (or object) like this:

var data = [
 'id' = 2961,
 'text' = 'stuff 2',
 'link' = '<a href="http://link/index.php?view=page&id=2961" target="_blank" title="title">atext1</a>',
 'icon1' = '<img src="img/icon_1.gif" class="icon" title="icon1" />12',
 'icon2' = '<img src="img/icon_2.gif" class="icon" title="icon2" />4',
 'icon3' = '<img src="img/icon_3.gif" class="icon" title="stuff 5: long title" />'
];

So far have I only been able to get the id. I tried splitting the td.html() value with var tdspilt = $('td', tr).html().split(' - ');, but that gives 2 problems. 1) Loss of jquery functions on tdsplit array, and 2) .html() replaces & with &amp;

var tr = 'above tr row';
var data = [];
data['id'] = $('td', tr).eq(0).find('a').attr('href').match(/view=page&id=([0-9]+)/)[1];

How can I end up with desired result ?

  • 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-18T01:53:57+00:00Added an answer on May 18, 2026 at 1:53 am

    Here is a jsFiddle: http://jsfiddle.net/elektronikLexikon/tH6Yq/

    The link is identically with the expected link, even if it’s red, but I don’t know why.

    jQuery.fn.outerHTML = function(s) {
        return (s) ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();
    }
    function escapeRegExpStr(str){
      return str.replace(/[\[\]\\{}()+*?.$^|]/g, function(m){return '\\'+m;});
    }
    
    data['id'] = $('td', tr).eq(0).find('a').attr('href').match(/view=page&id=([0-9]+)/)[1];
    
    data['link'] = $('a', tr).eq(0).outerHTML();
    data['text'] = $('td', tr).eq(0).html().match(new RegExp(escapeRegExpStr(data['link'])+" - (.*?) - ", ''))[1];
    
    data['link'] = data['link'].replace(escapeRegExpStr($('a', tr).eq(0).html()), $('a', tr).eq(0).html().match(/(.*?) /)[1]);
    
    data['icon1'] = $('img', tr).eq(0).outerHTML();
    data['icon1'] += $('td', tr).eq(0).html().match(new RegExp(escapeRegExpStr(data['icon1'])+"(.*?) - ", ''))[1];
    
    data['icon2'] = $('img', tr).eq(1).outerHTML();
    data['icon2'] += $('td', tr).eq(0).html().match(new RegExp(escapeRegExpStr(data['icon2'])+"(.*?) - ", ''))[1];
    
    data['icon3'] = $('img', tr).eq(2).outerHTML();
    icon3title = $.trim($('td', tr).eq(0).html().match(new RegExp(escapeRegExpStr(data['icon3'])+"(.*?)\s*<\/span>", ''))[1]) + ": " + $('span:last', tr).attr("title");
    data['icon3'] = data['icon3'].replace(/>/, ' title="' + icon3title + '">');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a more specific version of my other question. I have created an
I'm reviving this question, and making it more specific: Is there a .NET framework
I noticed This question , but my question is a bit more specific. Is
This is kind of more generic question, isn't language-specific. More about idea and algorithm
This is less of a code-specific question and more of an Objective-C nomenclature question.
This question ties to my previous question but is more specific. Say I have
This is a more specific question to follow up on [another question that I
This is a more theoretical question, not a specific scenario: Let's assume, we have
This is more a general purpose programming question than language specific. I've seen several
I will be more specific with a question if I need to be, or

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.