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.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
J.Jiang
  • 11
  • 3
  • 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. – Sami Kuhmonen Aug 28 '17 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. – J.Jiang Aug 28 '17 at 10:29

0 Answers0