I'm using the following function to modify tags used for mouseover text:

function delHoverX()
{
  re = /(\bdsc00001\b)/i;

  imgTags = document.getElementsByTagName("img");
  for (i=0; i<imgTags.length; i++)
  {
    if (re.test(imgTags[i].title))
    {
      origTitle = imgTags[i].title;
      origAlt = imgTags[i].alt;
      imgTags[i].title.replace(re, "$1");
      imgTags[i].alt.replace(re, "$1");
      if (origTitle == imgTags[i].title && origAlt == imgTags[i].alt)
        {
        imgTags[i].title = "same";
        imgTags[i].alt = "same";
        }
    }
    else
    {
      imgTags[i].title = "";
      imgTags[i].alt = "";
    }
  }
}

It is being used on the following web page: http://huntsvillecarscene.smugmug.com/gallery/1144571

For some reason, the regexp.replace is not working. There is a test clause in there to help me diagnose some of what's going on.

I'm not a Javascript programmer. I only have a limited background in C. I've been working on this for 2 days and am frustrated out of my mind.

Any assistance appreciated.

Recommended Answers

All 3 Replies

Anyone?

Regular Expressions have always been very difficult for me, for some reason. I'd be happy to try to help when I have a bit more time later this week.

Can you post a very simple "test harness" version of your HTML here?

it should be \i not /i for case insensitive in your re (first line of code) so you are possibly never getting a match. its is easy to miss as some others are / (for example /g for whole string)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.