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 423,575 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 3,485 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

  #35  
Mar 6th, 2008
Ahh hold on a sec.

The index must be dynamic, I didn't see that before.

The user input can be anything like this:

Whereinput = "Coldstreet" ' streetname
Or
Whereinput = "Coldstreet 123A" ' streetname and streetnumber
Or
Whereinput = "Coldstreet 123A 12345" ' streetname and streetnumber and zipcode
Or
Whereinput = "Coldstreet 12345" ' streetname and zipcode
Or
Whereinput = "12345 Freezytown" ' zipcode and city
Or
Whereinput = "12345" ' zipcode
Or
Whereinput = "Freezytown" ' city

I "just" have to decide which combinations that are not allowed like the ones below.

Non valid search strings:

Whereinput = "123A" ' streetnumber alone
Or
Whereinput = "123A 12345" ' streetnumber and zipcode
Or
Whereinput = "123A Freezytown" ' streetnumber and city


I'll throw up some more code later on for review...



My current code actually handle different combinations as I described, but Not as long there are any spaces in streetname and/or cityname like this.

Cold Street
or
Freezy Town

Where = "Coldstreet 123A 12345 Freezytown"

Words = Split(Where, " ")

For i = 0 to Ubound(Words)

If i = 0 AND i < UBound(Words) AND IsNumeric(Words(i)) = False Then
 Response.Write i & " = Street: " & Words(i) & "<br>"
End If

If i = 1 AND i < UBound(Words) AND IsNumeric(Left(Words(i),1)) = True AND Len(Words(i)) < 5 Then
Response.Write i & " = Streetnumber: " & Words(i) & "<br>"
 ElseIf i = UBound(Words) AND IsNumeric(Left(Words(i),1)) = True AND Len(Words(i)) < 5 Then
Response.Write i & " = Streetnumber: " & Words(i) & "<br>"
End If

If i > 0 AND i < UBound(Words) AND (IsNumeric(Words(i)) = True) AND Len(Words(i)) >= 5 Then
 Response.Write i & " = Zipcode: " & Words(i) & "<br>"
 ElseIf i = UBound(Words) AND (IsNumeric(Words(i)) = True) AND Len(Words(i)) >= 5 Then
 Response.Write i & " = Zipcode: " & Words(i) & "<br>"
End If

If i > 0 AND i = UBound(Words) AND IsNumeric(Left(Words(i),1)) = False Then
 Response.Write i & " = City: " & Words(i) & "<br>"
ElseIf i = 0 AND i = UBound(Words) AND IsNumeric(Left(Words(i),1)) = False Then
 Response.Write i & " = City: " & Words(i) & "<br>"
End If

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