View Single Post
Old 11-09-2005, 09:50 AM   #1
bsquare
Member
bsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it isbsquare knows what time it is
 
Posts: 24
Karma: 2128
Join Date: Dec 2002
Using Wildcard in uri.replace?

Is it possible to use a wildcard in a uri.replace call in a script? It doesn't seem to be working for me in this case so I'm guessing not, but maybe I'm just using it incorrectly.

I'm trying to make a change on the Link URL in the RSS (http://www.onmilwaukee.com/rss/rss.xml) from this:
http://onmilwaukee.com/music/articles/gigs1105.html

to the print version this:
http://onmilwaukee.com/articles/print/gigs1105.html

Problem is the first sub dir is always changing, so in this example it is "/music/articles/" needs to change to "/articles/print/" it could also be "/market/articles/" or "/bars/articles/" Bascically it's the first thing after the ./com/*/articles/ that I need to change.

So right now I'm trying this:
document.onanchorlink = function(link) {
// Set referrer to original uri
link.referrer = link.uri;
// Rewrite uri to point to printable version
link.uri = link.uri.replace("onmilwaukee.com/*/articles/", "onmilwaukee.com/articles/print/");
};

With no luck. If I need to set that first virtual directory (/music/" as a variable, to trap it, I'm not sure how to do that. Sorry for the obviously script-newbee question, but I'm just now starting to learn this a (very) little.
Any suggestions?
bsquare is offline