dottedquad
02-20-2005, 06:25 PM
I know how to use search, match, and replace... I'm just alittle confused on how I would replace a 'section' of a line when I don't know what one part of the section is....
To clear any confusion about my question... In a cookie I 'may' at one time have this:
listperpage::3;listoption::2; //field1::index#;field2::index#
The part what i won't know always is the index# because in the select field i have onchange="set_sort_cookie(name, type, value);"
function set_sort_cookie(name, type, value){
var str = document.cookie; //set the whole cookie to a string
var pattern = /name./g; //set the pattern for the RegEx to check for
var result = str.search(pattern); //RegEx the cookie to find the cookie name we're looking for
if (result != -1) {
//code to replace line in cookie
}
}
where:
if (tresult != -1) {
//code to replace line in cookie
}
I don't know how I would replace a certain section... Could anyone give me a hand with this?
-Thanks,
Rich
To clear any confusion about my question... In a cookie I 'may' at one time have this:
listperpage::3;listoption::2; //field1::index#;field2::index#
The part what i won't know always is the index# because in the select field i have onchange="set_sort_cookie(name, type, value);"
function set_sort_cookie(name, type, value){
var str = document.cookie; //set the whole cookie to a string
var pattern = /name./g; //set the pattern for the RegEx to check for
var result = str.search(pattern); //RegEx the cookie to find the cookie name we're looking for
if (result != -1) {
//code to replace line in cookie
}
}
where:
if (tresult != -1) {
//code to replace line in cookie
}
I don't know how I would replace a certain section... Could anyone give me a hand with this?
-Thanks,
Rich