0

I have the following RegEx, which works in the RegEx online tester: https://regex101.com/r/sZkhfs/1

What I want to do is get the whole text String between "Freigaben: " and any text string followed by a ":" (colon).

Pattern "(?<=Freigaben: )([\S\s]*?)(?=\s[a-zA-Z]++:)"

Test String "Freigaben: BLA BLABLABLABLABLABLBAL test ... Empfehlungen:"

When I try to run it in my VBA code I face an 5018/5017 error, which means the pattern is wrong, but I do not figured it out how to change it accordingly so that it will run in my VBA Code. Any ideas?

smartini
  • 404
  • 6
  • 18
  • 1
    `Freigaben:\s*([\S\s]*?)(?=\s+[a-zA-Z]+:|$)` and grab the `Submatches(0)`. – Wiktor Stribiżew Sep 17 '19 at 16:24
  • wow, yes that worked thanks! I had to collect submatches number 3, but I guess it's related to the array collection. – smartini Sep 17 '19 at 16:26
  • still have to figure out what the differences mean in the pattern to VBA. I could see that "lookbehind" is not possible in VBA, but isn't it a lookbehind somehow? – smartini Sep 17 '19 at 16:28
  • If you mean `(?=...)`, it is a lookahead, not a lookbehind. The VBA regex package is built on ECMAScript 5 specs and it supports a lot of things, but not lookbehinds and not possessive quantifiers like `++`. – Wiktor Stribiżew Sep 17 '19 at 16:34

0 Answers0