I have a string like:
"super exemple of string key : text I want to keep - end of my string"
I want to just keep the string which is between "key : "
and " - "
. How can I do that? Must I use a Regex or can I do it in another way?
I have a string like:
"super exemple of string key : text I want to keep - end of my string"
I want to just keep the string which is between "key : "
and " - "
. How can I do that? Must I use a Regex or can I do it in another way?
As I always say nothing is impossible:
Hope That I Helped.
If you are looking for a 1 line solution, this is it:
The whole 1 line solution, with
System.Linq
:Perhaps, a good way is just to cut out a substring:
Here is the way how i can do that
This returns only the value(s) between "key :" and the following occurance of "-"
Regex is overkill here.
You could use
string.Split
with the overload that takes astring[]
for the delimiters but that would also be overkill.Look at
Substring
andIndexOf
- the former to get parts of a string given and index and a length and the second for finding indexed of inner strings/characters.