Your question is unclear, the source of the data is unknown and there are a few typoes.
This JQuery (1.9.1)
var ihref = "";
var col = 'somedata';
$("a").click(function (i) {
ihref = $(this).attr('href');
if (ihref.match(/javascript:\s*sort\(\d+\).*/i)) {
ihref = ihref.replace(/javascript:\s*sort\((\d+)\).*/i,"http://www.w3schools.com/sor=$1&sortBy=" + col);
$(this).attr('href',ihref);
alert("As a demonstration, you\'ll see the link is rewritten when a javascript:sort url is clicked.");
}
});
Will convert all javascript:void links as you wanted. I did change the dummy url to w3schools.com
because the good folks who own w3 permit their site to be loaded in Iframes which is necessary to easily demonstrate that this code works.
Of course, JQuery only works when JS is enabled. Still, since you started with JQuery, I thought I might show you a working demonstration.
(The links don't actually work, because w3schools doesn't have pages at those points, but you can see in the status bar, the links are rewritten).
If you're retrieving the page via cfhttp.filecontent, you can do something like this
<cfset cfhttp.filecontent = ReReplaceNoCase(cfhttp.filecontent,"javascript:\s*sort\((\d+)\);?","http://www.w3schools.com/sor=\1&sort=asc","ALL")>
The ReReplaceNoCase()
was tested against this sample code..
<cfset cfhttp = {} />
<cfset col = "somedata" />
<cfsavecontent variable="cfhttp.filecontent">
<a href="javascript:void(0);">test - will not alter url</a><Br />
<a href="javascript:sort(53)">test - will alter url</a><Br />
<a href="javascript: sort(53)">test - will alter url</a><Br />
<a href="http://www.w3schools.com">test - will not alter url</a><Br />
</cfsavecontent>
<cfset cfhttp.filecontent = ReReplaceNoCase(cfhttp.filecontent,"javascript:\s*sort\((\d+)\);?","http://www.w3schools.com/sor=\1&sortBy=#col#","ALL")>
<cfdump var="#cfhttp#">