I used regex in the past to validate input, but I wonder if they can let you parse a complex string.
I have a headline like this:
I want to be able to parse, say, a file name.
I am currently doing this (after parsing the headers):
this.FileName = headers[1].Substring(headers[1].IndexOf("filename=\"") + "filename=\"".Length, headers[1].IndexOf("\"\r\n", headers[1].IndexOf("filename=\"")) - (headers[1].IndexOf("filename=\"") + "filename=\"".Length));
But it is disgusting and ugly.
Can regex solve this problem more elegantly? I understand the basics of syntax, so if it can solve it, can someone show me how to parse this with a regex:
"+Name=Bob+Age=39+"
I probably can solve the rest myself then.
Thank.
source
share