• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

RegExp bug ?

New Here ,
Feb 10, 2017 Feb 10, 2017

Copy link to clipboard

Copied

Hello,

it's drive me crazy...

I'm have test this sample code with node.js, in a developper console (firefox), in ExtenSript Toolkit and in AfterEffects:

var reg = new RegExp("^(?!.*auto-save).*aep$");

var string1 = "Comp.aep"

var string2 = "Comp auto-save.aep"

alert(reg.test(string1)+ " "+ reg.test(string2));

What i want is find "aep" in a string but exclude "auto-save"; easy...no?

All javascript engines return correct result ("true false") but not ExtendSript nor AfterEffects ("true true").

TOPICS
Scripting

Views

644

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 23, 2017 Feb 23, 2017

Copy link to clipboard

Copied

LATEST

It seems to be a bug, but I can't find any information if that is because negative lookahead regex was not implemented in the javascript engine extendscript is using or a bug in extendscript itself.

Either way, you can achieve what you are trying to do by using two regexes and testing the string against both:

var reg1 = new RegExp("aep$");

var reg2 = new RegExp("auto-save");

var string1 = "Comp.aep"

var string2 = "Comp auto-save.aep"

alert((reg1.test(string1) && !reg2.test(string1)) + " " + (reg1.test(string2) && !reg2.test(string2)));

// Alerts "true false"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines