Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 373
  • Last Modified:

Regular Expression to parse the domain name from HTTP_REFERER server variable

hi,

I need a regular expression that can parse the HTTP_REFERER server variable and extract the domain name.  Any help is greatly appreciated.

Thanks, Nauman.
0
nauman_ahmed
Asked:
nauman_ahmed
2 Solutions
 
laotzi2000Commented:
how about this one?
        Dim ref As String = (Request.ServerVariables("HTTP_REFERER"))
        If ref <> "" Then
            Dim str As String() = ref.Split("/")
            Response.Write(str(2))
        End If
0
 
raterusCommented:
Or a regex solution,
        Dim m As System.Text.RegularExpressions.Match = System.Text.RegularExpressions.Regex.Match(Request.ServerVariables("HTTP_REFERER"), "http://([^/])+")
        Dim domainname As String = m.Groups(1).Value
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now