Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a string format like following !
C#
string data = @usertext(Enter Your Code, date, test, bla, bla,bla,......) ;
//OR
string data = @usertext(Give Your data, date, test, bla, bla,bla,......) ;


Even it can be like
C#
string data = @usertext(Enter Your Code) ;
//OR
string data = @usertext(Give Your data)


That means the portion of bracket can be separated using comma or even there can have only one portion like second sample.

At first the code will check "is there @usertext" in the string. If @usertext is found there then it will parse the string & will take the first portion of bracket "Enter Your Code" or "Give Your data" from first or second sample of string. then I will get value using this portion. Then I will replace whole string by using this value.


Please keep in mind that there can have many thing before or after @usertext portion Like
C#
string data = @variable(composite, @usertext(Give Your data,data,test));
//OR
string data = Menu, @usertext(Give Your data), Table; 


My work is only with the portion of "@usertext(Give Your data)" OR @usertext(Give Your data,data,test). I need to pick the first portion of first bracket then I will get value using this portion and whole "@usertext(Give Your data,data,test)" will be replaced by this vaue.
Posted
Updated 1-Feb-15 23:27pm
v3
Comments
phil.o 2-Feb-15 5:23am    
Completely unclear. What is @usertext?
Nilendra Nath 2-Feb-15 5:32am    
Please provide a sample input/ inputs and output/ outputs so that we can understand what exactly problem is?
sachi Dash 2-Feb-15 5:37am    
input is a string & we need to check this string is there @usertext or not. if there is @usertext then you will find a format with @usertext and we need to parse "Enter your Code".

input: string data= @usertext(Enter Your Code, date, test, bla, bla,bla,......);

output: Enter Your Code
Sujith Karivelil 2-Feb-15 5:48am    
I think its better you provide a sample input and expected output. to get proper solution
sachi Dash 2-Feb-15 6:24am    
Sample input: @usertext(Enter Your Code, date, test, bla, bla,bla,......);
output:Enter Your Code

Always want to get the first portion inside the bracket.

1 solution

Use substring method to parse the string
 
Share this answer
 

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