Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 03-16-2012, 01:58 PM
Zaaka Zaaka is offline
Senior Member
 
Join Date: Aug 2002
Location: Teesside, UK
Posts: 217
Default What is the easiest way to split street numbers from a string

I have a list of addresses that I have in a Stringlist, which are in the format

40A Winterbourne Street

Is there an easy way to split the string so that '40A' would go into the street_number string and 'Winterbourne Street' into a street_name string?

also I have addresses that are like : 11 - 15 Winterbourne Street, and would require '11 - 15' in the street_number string
  #2  
Old 03-16-2012, 03:44 PM
Norrit Norrit is offline
Moderator
 
Join Date: Aug 2001
Location: Landgraaf
Posts: 7,335
Default

There are several approaches possible, but none of them guarantee 100% coverage.
  #3  
Old 03-17-2012, 12:19 AM
Zaaka Zaaka is offline
Senior Member
 
Join Date: Aug 2002
Location: Teesside, UK
Posts: 217
Default Another way round it

Would it be easier to just remove and words longer that 1 character?

Could anyone point me to any script that may help?
  #4  
Old 03-17-2012, 10:41 AM
Donovan Donovan is offline
Senior Member
 
Join Date: Jan 2011
Posts: 150
Send a message via Skype™ to Donovan
Default

Look up the RXstrUtil Library

That may help, but if there is not defined format there is no guarantee of the results

Regards

Donovan
  #5  
Old 03-18-2012, 07:35 PM
JimFFlagg JimFFlagg is offline
Junior Member
 
Join Date: Mar 2012
Location: Phoenix AZ
Posts: 6
Default

As long as the formatting stays consistent then you could copy to the position of the first space.

Code:
Var
       TestVar : String;
       StreetNumber : String;
Begin
       TestVar := '40A No Where St.';
       StreetNumber := Copy(TestVar,0,Pos(' ',TestVar)-1);
    ShowMessage(StreetNumber);
End;
This will only work if there is always a space after the street number and never a space in the street number.

Not sure if this helps.
Closed Thread

Tags
number, split, street, string

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 05:25 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.