Need a good approach to solve this problem. I have multiple strings. For example, “LOT 37 DISTRICT PLAN BCS321 NW SEC 1”. Now, I want to extract the LOT|LT|L which is 37. PLAN|PLN|PL which is BCS321 and SECTION|SEC|SECT|S which is 1. But the problem is with different scenarios that come. I am attaching some scenarios and I want help from the community if you can help me come up with some good approach to solve this problem. Much much appreciated and waiting for your response. Thanks.
Can you also share expected output for each sample?
But it may be difficult because we cannot tell header and data apart. For example, in case of PL is included in data such as LotAPLB : there is a possibility (Lot A) (PL B) OR (Lot APLB)
@Yoichi plan doesn’t have any character after the number. It might have character only before number.
And yes there are different possibilities there can be section if not then sec if not then s or the string doesn’t contain that.
@Steven_McKeering your solution is good. I am just brainstorming. We can do this for example for Lot. We can see if Lot exists then we run regex for Lot only. If LT exists then regex for LT. And so on. This should work, right?
Can you do one more thing like can this regex be modified to pick the first element found not multiple? For example, the second example matches two items. Can you modify it to collect the first matching element?
Also do comment on the brainstorming I did with you.
@Steven_McKeering man your regex rocked. I made few changes with that and it works now. I am keeping this thread for a day or two. If I have any question, I’ll post here and if not i’ll mark your answer as solution. Again, big thanks.