I am wondering how to extract the numeric string in a url using javascript? say to get 1234 in http://example.com?uid=1234
            Asked
            
        
        
            Active
            
        
            Viewed 34 times
        
    0
            
            
         
    
    
        Alan Moore
        
- 73,866
- 12
- 100
- 156
 
    
    
        Blake
        
- 7,367
- 19
- 54
- 80
- 
                    Check out http://stackoverflow.com/questions/2090551/parse-query-string-in-javascript – fjc Feb 18 '15 at 10:06
1 Answers
0
            
            
        use regular expressions. \d is any digit, + is 1 or more.
var str = 'http://example.com?uid=1234';
var regexp = /\d+/;
str = str.match(regexp);
console.log(parseInt(str));
 
    
    
        Joe Fitter
        
- 1,309
- 7
- 11