Results 1 to 1 of 1

Thread: replace() and regex question...

  1. #1
    Join Date
    Feb 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default replace() and regex question...

    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);"

    Code:
            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
    Last edited by dottedquad; 02-20-2005 at 06:30 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •