Hello everyone,
First of all, I will make available here the .txt file I’m using: 12-03-2020 02_41_10_PM.txt (2.1 KB)
I am using a Regex to capture all item codes from a .txt file based on a specific pattern that these codes have. In the .txt file I uploaded here, this is the Item codes (BCU302, BSX2339568, BCU302). This is my regex:
It works very well, but the only problem is when some item code is repeated in the .txt. When this happens, the Regex takes all the duplicates and counts as one. I would like to know if there is any way for my Regex to capture all the .txt codes, regardless of whether it is repeated or not.
@req7
give a try on following for getting the count of all matches
System.Text.RegularExpressions.Regex.Matches (myString,
“[A-Z]{3}[0-9]{3} | [A-Z]{3}[0-9]{7} | [A-Z]{3}[0-9]{6} |
[A-Z]{2}[0-9]{7} | [A-Z]{3}[0-9]{5}[A-Z]{1} |
[A-Z]{2}[0-9]{6}[A-Z]{1}”).Count
I saw that this Regex counts the number of items that matches the specified pattern, but I would like to capture those items.
I want to capture all the items in the .txt, because then I will create an excel with those items.