User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP section within the Web Development category of DaniWeb, a massive community of 427,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,192 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP advertiser: Lunarpages ASP Web Hosting

Using REGEXP in searching

Join Date: Feb 2008
Posts: 135
Reputation: TobbeK is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 3
TobbeK TobbeK is offline Offline
Junior Poster

Re: Using REGEXP in searching

  #43  
Mar 7th, 2008
The final try on this, before find some other approach to it.


I works sometimes, and orther time some results are strange when spaces are present or not.

What I have try to achive here is to concatenate the streetadress with streetnumber. It doesn't work very well.

The purpose of the possibility to do searches like this is to actually return what the user ask for, a more detailed question will return more exact hits

Example:
A string like this is containing very exact information for db search.
whereinput = "Coldstreet, 123A, 12345, Freezytown"
A string like this is just as exact for db search.
whereinput = "Coldstreet, 123A,12345"

Less exact but enough for db search
whereinput = "Coldstreet, 123A"
Or
whereinput = "12345"
Or
whereinput = "12345, Freezytown"
Or
whereinput = "Freezytown"

Also
I have created a variable (hybrid) for different inputs which can be either city, county or state


whereinput = "Coldstreet, 123A, 12345, Freezytown"
whereinput = Trim(whereinput)

where = Split(whereinput, ",")


For i = 0 to Ubound(where)

If i = 0 AND i < UBound(where) AND IsNumeric(where(i)) = False Then
  	Session("where") = where(i)
	adress = session("where")
ElseIf adress <> "" AND i = 1 AND i < UBound(where) AND IsNumeric(Left(where(i),1)) = True AND Len(where(i)) < 5 Then
 	Session("where") = where(i)
 	gatunr = session("where")
	adress = adress &" "& streetnumber
 Response.Write i & " = Adress: " & adress & "<br>"

ElseIf adress = "" AND i < UBound(where) AND IsNumeric(Left(where(i),1)) = True AND Len(where(i)) < 5 Then
  	Session("where") = where(i)
	streetnumber = session("where")
	adress = streetnumber
 Response.Write i & " = Adress: " & adress & "<br>"
End If

If i < UBound(where) AND (IsNumeric(where(i)) = True) AND Len(where(i)) >= 5 Then
 Response.Write i & " = Postnr: " & where(i) & "<br>"
	Session("where") = where(i)
	zipcode = session("where")
 ElseIf i = UBound(where) AND (IsNumeric(where(i)) = True) AND Len(where(i)) >= 5 Then
 Response.Write i & " = Postnr: " & where(i) & "<br>"
	Session("where") = where(i)
	zipcode = session("where")
End If

If i > 0 AND i = UBound(where) AND IsNumeric(Left(where(i),1)) = False Then
 Response.Write i & " = City: " & where(i) & "<br>"
  	Session("where") = where(i)
	hybrid = session("where")
 ElseIf i = 0 AND i = UBound(where) AND IsNumeric(Left(where(i),1)) = False Then
 Response.Write i & " = Address/City/County/State: " & where(i) & "<br>"
  	Session("where") = where(i)
	hybrid = session("where")
End If

Next



If InStr(zipcode," ") <> 0 Then
zipcode = Replace(zipcode," ","[\ ]?")
End If



SQL = "SELECT CL.organisation, CA.address,CA.zipcode,CA.city,RG.state,RG.stateID,KO.county,KO.countyID "&_
"FROM tbclientaddress CA "&_
"JOIN tbclients CL ON CA.clientlink = CL.clientID "&_
"JOIN tbstate RG ON CA.state = RG.stateID "&_
"JOIN tbcounty KO ON CA.county = KO.countyID "&_
"WHERE (REPLACE(CL.searchwords,'-','') REGEXP '[[:<:]]"&what&"'" &_
"OR REPLACE(CA.phone,'-','') REGEXP '[[:<:]]"&what&"'" &_
"OR REPLACE(CL.organisation,'-','') REGEXP '[[:<:]]"&what&"')" &_
"AND (REPLACE(CA.address,' ','') REGEXP '[[:<:]]"&address&"' "&_
"AND REPLACE(CA.zipcode,' ','') REGEXP '[[:<:]]"&zipcode&"' )" &_
"AND (REPLACE(CA.city,'-','') REGEXP '[[:<:]]"&hybrid&"' " &_
"OR REPLACE(KO.county,'-','') REGEXP '[[:<:]]"&hybrid&"' " &_
"OR REPLACE(RG.state,'-','') REGEXP '[[:<:]]"&hybrid&"') "
Set RS = Server.CreateObject("ADODB.recordset")
RS.Open SQL,Conn


Do While Not RS.EOF

etc ... etc ...
Last edited by TobbeK : Mar 7th, 2008 at 12:47 pm.
Reply With Quote  
All times are GMT -4. The time now is 10:32 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC