473,435 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,435 software developers and data experts.

how to parse an address string

given an address in a string, i need to parse the address from the string and return the structure Address.

Signature: Address parseAddress(String address)
Input: String with address(e.g. “Lunkad Tower, 6th floor, \r\n Viman Nagar, \r\n Pune 411014")
Output: The structure Address

public class Address
{
public string Street {get;set;}; // Lunkad Tower, 6th floor
public string Locality {get;set;}; // Viman Nagar
public string City {get;set;}; // Pune
public string State {get;set;}; // MH, Maharashtra
public string PostalCode {get;set;}; // 60611
public string Country {get;set;}; // e.g. India, IN
}
Expected Output:
the application should parse all the given addresses in the attached input file. The output should be in a text file containing all the parsed addresses, where each parsed output address is in the following format:
Street|Locality|City|State|PostalCode|Country
Each address output should be in a new line.
In case any of the address field is missing, leave the space blank between the “|” (pipe) separators. Don’t remove the pipe separators.
For example, if State is not mentioned in the input string, the output should be: Street|Locality|City| |PostalCode|Country

can anyone help me write the code???
Jul 8 '10 #1
1 5680
you can use the Java String Tokenizer class to split on certain characters

String Tokenizer/

You'll be able to extract the information that you need and then reassemble it in the format that you want.
Not sure if this is the most efficient way of doing it, but it will definitely work
Jul 9 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Martoni | last post by:
I need to parse a string with an embedded email address. The string always has the format NAME (name@domain) SOMETEXT. What I need to get is the email address as name@domain. I came up with this...
2
by: N | last post by:
Hi, I would like to parse out each value that is seperated by a comma in a field and use that value to join to another table. What would be the easiest way to do so without having to write a...
9
by: Danny | last post by:
HI again Is there a nifty function in access that will: 1. return the amount of occurances of a small string within a larger string? this<br>is<br>a<br>test would return 3 for <br>
19
by: linzhenhua1205 | last post by:
I want to parse a string like C program parse the command line into argc & argv. I hope don't use the array the allocate a fix memory first, and don't use the memory allocate function like malloc....
16
by: Charles Law | last post by:
I have a string similar to the following: " MyString 40 "Hello world" all " It contains white space that may be spaces or tabs, or a combination, and I want to produce an array...
4
by: Phil Mc | last post by:
OK this should be bread and butter, easy to do, but I seem to be going around in circles and not getting any answer to achieving this simple task. I have numbers in string format (they are...
1
by: Dan Somdahl | last post by:
Hi, I am new to ASP but have what should be a fairly simple task that I can't figure out. I need to parse a string from a single, semi-colon delimited, 60 character field (el_text) in a recordset...
1
by: (2b|!2b)==? | last post by:
I am expecting a string of this format: "id1:param1,param2;id2:param1,param2,param3;id" The tokens are seperated by semicolon ";" However each token is really a struct of the following...
2
by: tekt9t9 | last post by:
Hello I want to parse a string which holds a integer value to an int. The Interger.parseint() throws an exception. e.g If i try to execute the following code: i =...
5
by: pranyht | last post by:
for example if user enters Passing the parseAddress function "A. P. Croll & Son 2299 Lewes-Georgetown Hwy, Georgetown, DE 19947" returns: 2299 Lewes-Georgetown Hwy A. P. Croll & Son Georgetown...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.