Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing a hyperlink 1

Status
Not open for further replies.

lck092580

Programmer
Jun 19, 2002
440
CA
Hi,

Is there a way to update a record that has a hyper link and replace anything before .domain.com with "" so if we had something like:

We'll be left with domain.com

I don't want to just use a replace(domain, " "") because if the domain was:

then it wouldn't work. I tried to use a wild card in the replace statement but it wouldn't work. Any ideas?
 
One method would be to write a little function to count and determine the number of periods. Your parsing would then need to be based on the next to last period position + 1. htwh.

Steve Medvid
"IT Consultant & Web Master"

Chester County, PA Residents
Please Show Your Support...
 
Something like this?
Code:
Function ReturnDomain(Hyperlink As String) As String
ReturnDomain = Mid(Hyperlink, (InStrRev(Hyperlink, ".", InStrRev(Hyperlink, ".") - 1)) + 1)
End Function

CMP


(GMT-07:00) Mountain Time (US & Canada)
 
Another way:
Function ReturnDomain(myHyperlink) As String
If Trim(myHyperlink & "") = "" Then Exit function
Dim a
a = Split(myHyperlink, ".")
If UBound(a) > 1 Then
ReturnDomain = a(UBound(a) - 1) & "." & a(UBound(a))
Else
ReturnDomain = myHyperlink
End If
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi,

THanks for all the great replies. Is there a way to just use an update query to do it? I'm not good with access and I don't know how in corporate this into my database.
 
SQL code:
UPDATE yourTable SET yourField = ReturnDomain([yourField])
WHERE yourField Like '*.*.*'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
It works!!! THANKS PHV!

I'm going to dedicate some more time on figuring out how to use the modules properly. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top