Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
For Eg. ?$255*$50*$50*?
hey, suppose i have above incoming string format near about 200 word are there. from that ?...? these are start and end notation. and i want to extract data from $....* can i use array for this or which is better solution for this. i am new in this field.
Posted

Using or not using arrays is irrelevant to the problem of string parsing. If you cases are as simple as your data sample, learn how to use Regular Expressions. See:
http://en.wikipedia.org/wiki/Regular_expression[^],
http://msdn.microsoft.com/en-us/library/hs600312.aspx[^].

Regular Expressions are fully supported in .NET. Use the class System.Text.RegularExpressions.Regex, http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^].

—SA
 
Share this answer
 
v2
Comments
Abhinav S 22-Aug-11 2:38am    
Good answer. 5.
Sergey Alexandrovich Kryukov 22-Aug-11 2:47am    
Thank you, Abhinav.
--SA
Oludayo Alli 22-Aug-11 14:42pm    
+5
Sergey Alexandrovich Kryukov 22-Aug-11 15:44pm    
Thank you, Sunny.
--SA
Like SA suggests that is a job for Regex.

Here's how I would do it.
C#
List<string> words = new List<string>()
MatchCollection matches = Regex.Matches("?$255*$50*$50*?"
, "\$(?<word>.+?)\*");
foreach(Match match in matches)
    words.Add(match.Groups["word"].Value);


In addition to the links provided by SA, there are plenty of Regular expression articles here on the Code Project[^]
 
Share this answer
 
v5
Comments
Abhinav S 22-Aug-11 2:39am    
Good you have provided the regex. 5.

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