Showing posts from June, 2006

Javascript RegExp: replace parameter value in query string

Task: change the value of parameter 'tid' in given querystring.
Original querystring:

var linkParam = 'tid=8&id=11008&location=news';

New 'tid' parameter value:

var tagId = 12;

You can do it using 'replace' function. Final code to replace:

var tagIdReg = /[tid=](\d+)[&]/i;
document.write(linkParam.replace(tagIdReg, '='+tagId+'&'));

But if you need just extract 'tid' value use 'exec':

var tagIdReg = /[tid=](\d+)[&]/i;
var regResult = tagIdReg.exec(linkParam);

Functional desktop background

While ago I created this extremely useful :), yes, that's right, for probably every web developer, the Windows desktop backgroud. It should fit most of the today's desktop screens resolutions. Dimensions of background is: 1680x1200. For more compatibility the format of the file is windows bitmap. Download it, unzip and copy to your C:\windows folder. It will become available on "Desktop" tab of "Display Properties" window.

It looks like this (but bigger, yeah):