Regex negative lookahead not working in LC?

Andreas Bergendal andreas.bergendal at gmail.com
Sat Aug 19 11:37:30 EDT 2023


Hi all,

I’m trying to run a matchChunk regex on an LC script text, with the aim of scoring a hit only if a word is NOT commented out by one of the comment methods.

This regex works beautifully when tested in regex101.com (PCRE flavor):

(?i)^(?:(?!--|#|\/\/).)*\b(myHandler)\b

When applied on the text

command myOtherHandler
   # myHandler
  // myHandler
  -- myhandler
  notMyHandler
end myOtherHandler

it should score zero matches and it does.


When applied on the text

command myOtherHandler
   # myHandler
  // myHandler
  -- myhandler
   myHandler
end myOtherHandler

it should score 1 match and it does.

Applying the same regex in LC does NOT score any match in the latter example though.

Why? Doesn't negative lookahead work in LC? (v9.6.9 stable.)

Best,
Andreas


More information about the use-livecode mailing list