Folks, here is another on "regex: match everything, but not ...", but so far non seems to fit my simple question.
I need to program my Excel function to separate strings from their preceding enumerators (similar as done here: VBA regex: extract multiple strings between strings within Excel cell with custom function)
My first simple string is: "1 Rome; 2 London; 3 Wembley Stadium"
My second string looks like: "1.1 Winner; 2.1 Looser; 3.3 Penalties (always loose, dam)"
And I need to extract only the names but not the ranks ( eg. "Rome; London; Wembley Stadium" and "Winner; Looser; Penalties (always loose, dam)").
Using a regex tester (https://extendsclass.com/regex-tester.html), I can simply match the opposite by:
([0-9]+\s*) and it gives me:
"1 Rome, 2 London, 3 Wembley Stadium".
But how to reverse it? I tried something like:
[^0-9 |;]+[^0-9 |;], but it also excludes white spaces that I want to maintain (e.g. after the comma and in between Wembley and Stadium, ... "1 Rome, 2 London, 3 Wembley Stadium"). I guess the "0-9 " needs be determined somehow as one continuous string. I tried various brackets, quotation marks, \s*, but nothing jet.
Note: I'm working in a visual basic environment and not allowing lookbehinds!
Note: My solutions needs to be compatible across Excel versions as far as possible!




;& looping removing leading spaces/digits would be a simple way. If you want the names in a single string together then just match the digit part(\d*(\.?\d+)\s+)and RegEx.Replace it with"".(?:\.\d+)*to match zero or more occurrences of a.and one or more digits,\d+(?:\.\d+)*\s*(.*?)(?=;\s*\d+(?:\.\d+)*\s|$)match.Submatches(0)only. Of course the number will land in the whole match.