0

I need to extract a string by judging two indicated strings from a long string in C#, e.g. there is a string

"weight: 30 pounds. Height: 2 meters."

I need to extract the string "30" by judging that its front is "weight: " and its behind is " pounds". I cannot use index as I have many strings like this to read. Sometimes the weight can be 100 pounds which makes the extraction from index incorrect. How to do this? Thanks.

2
  • Is there something that's always there? I mean, is it always "weight: x pounds."? Then regexps or just substrings with indices from the string will work. Commented Aug 28, 2017 at 10:22
  • Thanks. it is always "weight: x pounds." However the length of x can vary. There are many parameters written in one string and I just need to extract one value from one parameter. Commented Aug 28, 2017 at 10:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.