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 401,969 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,852 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

  #44  
Mar 9th, 2008
The final .... (probably)

Now it is actually does what it should.

Any input combination is handled as it is supposed to.

Even an an input like this is separated in the manner it should.
whereinput = "Cold street 123 A 123 45"

Output:
Cold street 123 A
123 45

I have played a bit with the index and the values stays at the same index positions but are placed into different variables.

Everything seems to work. I still have one piece left, and that is the cityname that can appear at the very end of the string or by it's own. I havn't figured that out yet, and hopefully I get some help with that.

The streetname alone or a cityname alone should populate a variable named hybrid.
If there is any spaces in that string the first substring populate streetname second substring the hybrid variable.



whereinput = "Cold street 123 A 123 45"
whereinput = Trim(whereinput)

where = Split(whereinput, " ")

For i = 0 To UBound(where)


If i = 0 AND i = Ubound(where) AND IsNumeric(where) = False Then

	hybrid = where(i)

	ElseIf i = 0 AND i < Ubound(where) AND IsNumeric(where) = False Then
	streetname = where(i)

	ElseIf i = 1 AND i < Ubound(where) AND IsNumeric(where) = False Then
	streetname = where(i)

	ElseIf i = 2 AND i < Ubound(where) AND IsNumeric(where) = False Then
	streetname = where(i)

	ElseIf i = 3 AND i < Ubound(where) AND IsNumeric(where) = False Then
	streetname = where(i)

	ElseIf i = 4 AND i < Ubound(where) AND IsNumeric(where) = False Then
	streetname = where(i)

End If


If i = Ubound(where) AND IsNumeric(Left(where(i),1)) = True AND Len(where(i)) < 5  Then

	If i = 1 Then
	streetname = streetname&" "&where(i)
	End If

	If i = 2 Then
	streetname = where(i-2)&" "&streetname&" "&where(i)
	End If

	If i = 3 Then
	streetname = where(i-3)&" "&where(i-2)
	End If

	If i = 4 Then
	streetname = where(i-4)&" "&where(i-3) & " " &where(i-2)
	End If

	If i = 5 Then
	streetname = where(i-5)&" "&where(i-4) & " " &where(i-3) & " " & where(i-2)
	End If

	If i = 6 Then
	streetname = where(i-6)&" "&where(i-5) & " " &where(i-4) & " " & where(i-3)
	End If

	Response.Write(i &" = " & streetname  & "<br>")

End If


If i = Ubound(where) AND IsNumeric(Left(where(i),1)) = False  Then

	If i = 6 Then
	streetname = where(i-6)&" "&where(i-5) & " " &where(i-4) & " " & where(i-3)
	End If

	If i = 5 Then
	streetname = where(i-5)&" "&where(i-4) & " " &where(i-3) & " " & where(i-2)
	End If

	If i = 4 Then
	streetname = where(i-4)&" "&where(i-3) & " " & where(i-2)
	End If

	If i = 3 Then
	streetname = where(i-3)&" "&where(i-2)
	End If

	If i = 2 Then
	streetname = streetname & " " &where(i)
	End If

	If i = 1 Then
	streetname = streetname & " " &where(i)
	End If

	Response.Write(i &" = " & streetname  & "<br>")
	Response.Write(i &" = " & hybrid  & "<br>")

End If


If i = Ubound(where) AND IsNumeric(Left(where(i),1)) = True AND Len(where(i)) = 5  Then

	If i = 0 Then
	zipcode = where(i)
	End If

	If i = 1 Then
	streetname = where(i-1)
	zipcode = where(i)
	End If

	If i = 2 Then
	streetname = where(i-2) &" "& where(i-1)
	zipcode = where(i)
	End If

	If i = 3 Then
	streetname = where(i-3) &" "& where(i-2) &" "& where(i-1)
	zipcode = where(i)
	End If

	If i = 4 Then
	streetname = where(i-4) &" "& where(i-3) &" "& where(i-2) &" "& where(i-1)
	zipcode = where(i)
	End If

	If i = 5 Then
	streetname = where(i-5) &" "& where(i-4) &" "& where(i-2) &" "& where(i-1)
	zipcode = where(i)
	End If

	Response.Write(i &" = " & streetname  & "<br>")
	Response.Write(i &" = " & zipcode  & "<br>")

ElseIf i = Ubound(where) AND IsNumeric(Left(where(i),2)) = True AND Len(where(i)) = 2  Then

	If i = 4 Then
	streetname = where(i-4) &" "& where(i-3) &" "& where(i-2)
	zipcode = where(i)
	End If

	If i = 3 Then
	streetname = where(i-3) &" "& where(i-2)
	zipcode = where(i-1)&where(i)
	End If

If IsNumeric(Left(where(i-1),3)) = True AND Len(where(i-1)) = 3 Then

	If i = 2 Then
	streetname = where(i-2) '&" "& where(i-1)
	zipcode = where(i-1)&where(i)
	End If

End If

zipcode = where(i-1) & where(i)
Response.Write(i &" = " & zipcode  & "<br>")

End If


Next


Response.Write("<br>")
Response.Write("streetname: " & streetname) & "<br>"
Response.Write("zipcode: " & zipcode)  & "<br>"
Response.Write("hybrid: " & hybrid)
Reply With Quote  
All times are GMT -4. The time now is 6:46 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC