...

View Full Version : parse string question



angst
07-21-2004, 06:06 PM
hello,
I'm trying to parse my log file and extract data from it,
but i'm stuck on one part,,

i'm trying to get just the domain this line:

www.domain.com:05/28/2004 14:02:18 - Add.Info: Nas=142.0.0.10 (ID:) Port=32

i am able to remove everything in front of the www. because it appears the same number of characters in for every line, but the lenth of the name changes.

if i use:
strUrl = Mid(test,InStrRev(test , ":") + 1)
then i'm only left with everything after the :,

so how can i get just the domain, everything before : ?

thanks for ur time!

oracleguy
07-21-2004, 06:23 PM
You can use a regular expression to isolate the domain name.

This pattern should work:


([a-zA-Z0-9]{1,15}\.)+([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}


Assuming that there will always be a host header name (e.g. www) on the domain name. If that is not the case, ommit the red part of the pattern.

If you are unfamiliar with regular expressions check these links out:
http://authors.aspalliance.com/brettb/VBScriptRegularExpressions.asp
http://www.4guysfromrolla.com/webtech/031500-1.shtml



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum