/ Published in: Regular Expression
                    
                                        Use this to extract an HTML5 origin from a URI. $1 is the origin.
The square brackets are there to support IPv6 addresses.
Example:
var html5OriginRegex = /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/;
"http://www.google.com:42/foo/bar/baz.html".replace(html5OriginRegex, "$1")
== "http://www.google.com:42"
                The square brackets are there to support IPv6 addresses.
Example:
var html5OriginRegex = /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/;
"http://www.google.com:42/foo/bar/baz.html".replace(html5OriginRegex, "$1")
== "http://www.google.com:42"
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
 /^([\w-]+:\/*\[?[\w\.:-]+\]?(?::\d+)?).*/
Comments
                    Subscribe to comments
                
                