Got more questions? Find advice on: ASP | SQL | XML | Windows
Welcome to RegexAdvice Sign in | Join | Help

Parse param from Query String

  •  06-26-2008, 10:58 PM

    Parse param from Query String

    I'm trying to parse a Parameter value from the Query String in JavaScript

    E.g URLs: 

    http://www.contoso.com?key1=value1&key2=value2

    http://www.contoso.com?&key2=value2&key1=value1

     [window.location.search.substring(0) in JS automatically return portion after '?' so i just need to parse out the key-value]


    Result (in both cases)

    value1 (If i look up param 'key1') 

     

    I have the following  in Javascript but it does not work for all

     var match = /(?:\?|&)RU=(\S+)(&(\S+)*)/i.exec(window.location.search.substring(0));

    Please help

     
    -A 

     

View Complete Thread