?
Solved

Regular Expression to parse the domain name from HTTP_REFERER server variable

Posted on 2005-03-22
2
Medium Priority
?
368 Views
Last Modified: 2011-05-24
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
Comment
Question by:nauman_ahmed
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Assisted Solution

by:laotzi2000
laotzi2000 earned 800 total points
ID: 13603154
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
 
LVL 33

Accepted Solution

by:
raterus earned 1200 total points
ID: 13603637
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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question