This is my string:
"0949418001","12/12/2011","12/21/2011","0010043309","EFT ","Net 10 Days From Ship Date","","","FOB Origin/Collect","","","0000835369","DUPRE TRANSPORTS INC","DUPR ","0231653047","1/23/2012","Motor Fuel Dest","1049930","8784.00","8796.00","8784.00","UG6 ","N","0.196500","1726.06","25405.51","TAX ","REG","","PASADENA,TX,COP,RFYC (03FV)"," ","0000835369","835369","1726.06","01/23/2012","0.00","23679.45"
I want to get the date that is preceding the word "Motot Fuel Dest"
using regex. How can we get that?
Could use something like this...
/(?<=")[^"]+(?=","Motor Fuel Dest)/
Depending on your regex flavor the syntax may be different.
Edit: .NET version of solution
resultString = Regex.Match(subjectString, "(?<=\")[^\"]+(?=\",\"Motor Fuel Dest)").Value;
It's not something special, just lookbehind/lookahead capture only what you need.
This will also work...
var dateMatch = Regex.Match(myInputString, @"(?<Date>\d{1,2}/\d{1,2}/\d{4})"",Motor\sFuel\sDest");
DateTime theValue = DateTime.Parse(dateMatch.Groups["Date"].Value);
Then you have the value as a DateTime
in the theValue
field.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.