Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi all,
i am in big trouble, I have a query to read "address" from text message which i am getting from some where else and then it to other.

[Moved here from "solution"]

Ok,


we are working on an app which can detect the message from mail account

eg.

1. 16:50 Thu 25/09/14 >NOTIFICATION MFS: *CFSRES INC0003 25/09/14 16:49 RESPOND RESCUE ANIMAL P2 : @HOMESTEAD - LYNMOND 9 COBBLEDICK RD ECHUNGA MAP:ADL 183 Q12,CALLER:JULIEANNE RICE 0417806893 == LAMB STRANDED ON ISLAND IN DAM :ECHG34 MTB20 I SNOTIFY C :

2. 11:08 Thu 25/09/14 >NOTIFICATION MFS: *CFSRES INC0001 25/09/14 11:08 RESPOND RESCUE ANIMAL P2 9/4 MERLOT CT WYNN VALE MAP:ADL 84 H 1,CALLER:JACKIE KNOX 0439300697 == CAT STUCK IN DRAIN. :GGV311 SNOTIFY C TTG20 P :



we have requirement to fatch the address from the meassge and send it to other account in our app.
so what logic used to fatch the address with accuracy.

Pleas help me.


thanks in advance.........
Posted
Updated 25-Sep-14 1:51am
v2
Comments
Sinisa Hajnal 25-Sep-14 7:02am    
And your problem is?
[no name] 25-Sep-14 7:28am    
There is nothing at all here to help you with. No question, no description of a problem, just some information about you having a query.
ZurdoDev 25-Sep-14 8:46am    
Where are you stuck?

1 solution

I hope this gets you started: you may need to modify the code here depending on the range of possible formats the string you need to parse arrives in.
C#
private string[] split1 = new string[]{"P2"};
private string[] split2 = new string[] {"MAP"};
private char[] toTrim = new char[] {' ',':','@'};

public string responseToAddress(string response)
{
    string address = response.Split(split1,2, StringSplitOptions.RemoveEmptyEntries)[1];
    address = address.Split(split2, StringSplitOptions.RemoveEmptyEntries)[0];
    return address.Trim().TrimStart(toTrim);
}
You could also achieve something like this using a Regular Expression.
 
Share this answer
 
v2
Comments
_Kapil 26-Sep-14 2:01am    
i am not able to get form where i start to get address because if i hit google map("https://www.google.co.in/maps/preview") with any address keyword ,getting response from google map search.
Not able to identify its correct address or not.
BillWoodruff 26-Sep-14 2:42am    
Well, if you can't determine whether an address is correct, then I guess you do not need to solve this problem of string parsing ? I can't quite understand what you are trying to tell me here, but I'm glad you found the code useful in some way.
_Kapil 26-Sep-14 5:24am    
Can you clarify me that there is any solution for the problem that, You have a message text with any format and you have to fatch address from this text message.

eg.
11:08 Thu 25/09/14 >NOTIFICATION MFS: *CFSRES INC0001 25/09/14 11:08 RESPOND RESCUE ANIMAL P2 9/4 MERLOT CT WYNN VALE MAP:ADL 84 H 1,CALLER:JACKIE KNOX 0439300697 == CAT STUCK IN DRAIN. :GGV311 SNOTIFY C TTG20 P :


address: P2 9/4 MERLOT CT
BillWoodruff 26-Sep-14 6:26am    
The amount of code you have to write to parse any specific block of text from a string is directly related to how much the source string you are evaluating varies in content.

If you can reliably assume that "P2" is always present, and always marks the start of the address, and "MAP" is always present, and marks the end of the address, then you can use the code example given.

But, if the source string varies in other ways, you have to handle every possible other variation in your code.

What you need to do is find the format specification of the message string, and analyze it to generate the conditions you will test for.

If there is no specification, you have a problem.
_Kapil 26-Sep-14 6:47am    
@BillWoodruff.........
You are right,I think we to talk with our client to provide us some format so that we can identify the address.

thanks for yours valuable time.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900