I have a string I will present in a text box that will vary somewhat but has some format to it. The string is coming from a .pdf file. It will be formatted as below:
1
EA
2.00 2814-212-D003 0.00 0.00
LONG JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-213-703 Seq No: 9002
2
EA
2.00 2814-212-D003 0.00 0.00
LONG JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-214-703 Seq No: 9002
3
EA
2.00 2814-212-D004 0.00 0.00
SHORT JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-213-703 Seq No: 9003
4
EA
2.00 2814-212-D004 0.00 0.00
SHORT JACK PAD
Drawing: OPT
Due: 05/19/2023 Requester: NMB
Order: 2843HR-214-703 Seq No: 9003
I want to pull several items from this text in a loop. To put in perspective, this text is a purchase order from a customer.
I want to pull the line item, the qty, the part number, description, who drew it, and the due date for the line.
My problem is that the method I am using to get the info doesn't seem like the best option out there. How would one go about this in a more efficient manner?
I plan to loop through each line item(I figure there's a way to loop every 7 lines) and place each piece of data into a variable in a object I will create, and place those objects in a list.
So far I am getting some of the information with little effort but I feel I am doing it in a rather messy way. here is what I came up with this morning:
string startString = richTextBox1.Text;
string qty = startString.Substring(6, startString.IndexOf(' '));
int index = startString.IndexOf(' ');
index = startString.IndexOf(' ', index + 1);
string partNumber = startString.Substring(index, 14);
string description = startString.Substring(index+ 25, startString.IndexOf(":"));
once I build this list I will place this data into an excel sheet, which I will figure out later(one problem at a time!)
Use code like this
Here is the Regex pattern