Folks, there are already billions of questions on "regex: match everything, but not ...", but non seems to fit my simple question.
A simple string: "1 Rome, 2 London, 3 Wembley Stadium
" and I want to match just "1 Rome,
2 London,
3 Wembley Stadium
", in order to extract only the names but not the ranks ("Rome, London, Wembley Stadium
").
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!