Find a string in a string... Living hell.
-
Hi, How could i find a string in a string ? For exemple, lets say i have the string "Hello! (How are you) ?", How could i find the string in the parentheses ? Is there a function that would return the "How are you" ? If not, is there a way to find the position of the "(" and of the ")" ? Thanks :) Heel
-
Hi, How could i find a string in a string ? For exemple, lets say i have the string "Hello! (How are you) ?", How could i find the string in the parentheses ? Is there a function that would return the "How are you" ? If not, is there a way to find the position of the "(" and of the ")" ? Thanks :) Heel
Of the top of my head, if you are looking for a string that appears between brackets then this should work:
string myString = "Hello (how are you)?"; int start = myString.IndexOf("(")+1; int end = myString.IndexOf(")"); string subString = myString.Substring(start,end-start);
subString will contain "how are you" You might be able to do something with Regex as well, but I'm not real familar with that. -
Of the top of my head, if you are looking for a string that appears between brackets then this should work:
string myString = "Hello (how are you)?"; int start = myString.IndexOf("(")+1; int end = myString.IndexOf(")"); string subString = myString.Substring(start,end-start);
subString will contain "how are you" You might be able to do something with Regex as well, but I'm not real familar with that.that's pretty straight forward string parsing. living hell? no.
-
that's pretty straight forward string parsing. living hell? no.
hmm... have you heard of Regular Experession... do check them out.. they really can help you in finding patterns... while making Living Hell a 'bit' better place :) mE --------------------- A gasp of breath, A sudden death: The tale begun. A rustled page Passes an age: The tale is done.