Thread: RegExp quandary
View Single Post
Old 05-02-2005, 09:12 PM   #1
csh
Junior Member
csh began at the beginning.
 
Posts: 3
Karma: 10
Join Date: May 2005
Device: Sony PEG-T665C
Question RegExp quandary

Trying to filter a quick document composed of URLs for articles at news.com.com I wanted to follow up on. For example:

<A HREF="http://news.com.com/Quote+of+the+day+Hedge+fund+guy+laughing+butt+off/2110-1010_3-5690203.html?tag=st_lh">Article</A>

which I wanted to modify to:

<A HREF="http://news.com.com/2110-1010_3-5690203.html?tag=st.util.print">Article</A>

Here's what I came up with for the filter script:
//Script for converting news.com.com articles to print version with referrer
//Setup for checking for an RE
var regexp = /news\.com\.com/.*\+.*/

document.onanchorlink = function(link) {
// Set referrer to original uri
link.referrer = link.uri;
//If URL contains match to regexp
if ( link.uri.match(regexp) != null) {
//Then
// Rewrite uri to point to printable version
var junk = link.uri.match(regexp)[0];
link.uri = link.uri.replace(junk, "/news.com.com/");
link.uri = link.uri.replace("tag=st_lh", "tag-st.util.print");
//Endif
};
};

Problem is I end up with a status of:
Error: Exception reading script file "null": missing name after . operator (<embedded> #3)

What is wrong with my script? (Where did I go wrong?)

Any patient help would be greatly appreciated.
csh is offline