Using VB.NET, I have created an AddIn for Autodesk Inventor and the customer has a bunch of drawing number strings which follow this sort of scheme:
- P01867-13-TP09-001-4950-1775-1175-895-1125-835
- P01867-13-TP09-002-4950-1775-1045-895-1035
- P01867-13-TP02-019-L-1137-275-852-102
- P01867-13-TP02-019-L-1137-275-852-102
- P01867-13-TP02-019-R-1137-275-852-102
- P01867-13-TP02-021-L-1137-1055-1372
- P01867-13-TP02-021-L-1137-535-1027
- P01867-13-TP02-021-L-1137-795-1184
- P01867-13-TP02-021-R-1137-1055-1372
- P01867-13-TP02-021-R-1137-535-1027
- P01867-13-TP02-021-R-1137-795-1184
- P01867-13-TP02-025-L-1137-1315-1581
- P01867-13-TP02-025-R-1137-1315-1581
- P01867-13-TP03-005
- P01867-13-TP02-019-L-1137-275
- P01867-13-TP02-019-R-1137-275
- P01867-13-TP02-019-R-1137
- P01867-13-TP02-019-L-1137
In order to account for these groups of three digits within the variations I have created the following regex:
(\w*\d*-\d*-\w*\d*-\d*-\w-)(\d*)-(\d*)-(\d*)-(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-\w-)(\d*)-(\d*)-(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-\w-)(\d*)-(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-\w-)(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-\w-)(\d*)|(\w*\d*-\d*-\w*\d*-\d*-)(\d*)-(\d*)-(\d*)-(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-)(\d*)-(\d*)-(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-)(\d*)-(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-)(\d*)-(\d*)|(\w*\d*-\d*-\w*\d*-\d*-)(\d*)|(\w*\d*-\d*-\w*\d*-\d*)|.*(\w*\d*-\d*-)(\d*)-(\d*)-(\d*)-(\d*)-(\d*)|.*(\w*\d*-\d*-)(\d*)-(\d*)-(\d*)-(\d*)|.*(\w*\d*-\d*-)(\d*)-(\d*)-(\d*)|.*(\w*\d*-\d*-)(\d*)-(\d*)|.*(\w*\d*-\d*-)(\d*)|.*(\w*\d*-\d*-\w-)(\d*)-(\d*)-(\d*)-(\d*)-(\d*)|.*(\w*\d*-\d*-\w-)(\d*)-(\d*)-(\d*)-(\d*)|.*(\w*\d*-\d*-\w-)(\d*)-(\d*)-(\d*)|.*(\w*\d*-\d*-\w-)(\d*)-(\d*)|.*(\w*\d*-\d*-\w-)(\d*)
I now have to add the capability of looking for a sixth group of digits so figured I would ask here if there is a method within regex (which I may have overlooked) that will allow me to improve upon/simplify the above monster.