Hello,
I have a regex which runs and extracts an address from within a string (pager message), and the format of the address is normally something like this:
xx TERRELL CL ENDEAVOUR HILLS /ISAAC SMITH CR where the xx is the street number, and /ISAAC SMITH CR represents the nearest cross road / road.
Below i have copied some code I am using in my script, but for some reason it does not appear to be breaking the string down correctly, what I am trying to do is have the address be anything before / (if / exists in the string), then the cross road be anything between / and // if they exist (e.g. there are two cross roads). I then use this address to geocode latitude and longitude and go from there.
The strange thing though, is that alot of the time the geocoding is pulling up different streets that it thinks i mean, which is because my script is keeping the /STREET crossroad there, so for example instead of sending for geocoding xx TERRELL CL ENDEAVOUR HILLS it sends xx TERRELL CL ENDEAVOUR HILLS /ISAAC SMITH CR which means that the geocoder things i mean ISAAC SMITH CR rather than TERRELL CL. Have i missed something in my script that would cause this to error up?
The only exception to the above, is if there is a CNR in the string, then the address format is normally STREET 1 RD/STREET 2 RD where i do actually want to not strip the / out etc.
Thanks!
I have a regex which runs and extracts an address from within a string (pager message), and the format of the address is normally something like this:
xx TERRELL CL ENDEAVOUR HILLS /ISAAC SMITH CR where the xx is the street number, and /ISAAC SMITH CR represents the nearest cross road / road.
Below i have copied some code I am using in my script, but for some reason it does not appear to be breaking the string down correctly, what I am trying to do is have the address be anything before / (if / exists in the string), then the cross road be anything between / and // if they exist (e.g. there are two cross roads). I then use this address to geocode latitude and longitude and go from there.
The strange thing though, is that alot of the time the geocoding is pulling up different streets that it thinks i mean, which is because my script is keeping the /STREET crossroad there, so for example instead of sending for geocoding xx TERRELL CL ENDEAVOUR HILLS it sends xx TERRELL CL ENDEAVOUR HILLS /ISAAC SMITH CR which means that the geocoder things i mean ISAAC SMITH CR rather than TERRELL CL. Have i missed something in my script that would cause this to error up?
The only exception to the above, is if there is a CNR in the string, then the address format is normally STREET 1 RD/STREET 2 RD where i do actually want to not strip the / out etc.
Thanks!
PHP Code:
If Instr(1, ExtractedAddress, "/") > 0 and Instr(1, ExtractedAddress, "CNR") < 0 then
CleanedAddress = ExtractedAddress.Substring(0, ExtractedAddress.IndexOf("/"))
CrossRoads = ExtractedAddress.Substring(ExtractedAddress.IndexOf("/"),ExtractedAddress.Length - ExtractedAddress.IndexOf("/"))
Dim MainAddress() as String = ExtractedAddress.split("/")
hs.WriteLog("Guessed-Address", "Guessed Address = " & MainAddress(0))
elseIf Instr(1, ExtractedAddress, "/") > 0 and Instr(1, ExtractedAddress, "CNR") > 0 then
CleanedAddress = ExtractedAddress
else
CleanedAddress = ExtractedAddress
CrossRoads = ""
end if
Comment