Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    parse string question

    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!

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You can use a regular expression to isolate the domain name.

    This pattern should work:
    Code:
    ([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/brett...xpressions.asp
    http://www.4guysfromrolla.com/webtech/031500-1.shtml
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •