Regex error

People using regex should know about “(?!<A>)” and “(?<!<A>)”. It seems that “(?<!<A>)” does not work in Komodo JS script.

This works.

var myStr = "<A><D><D>";
myStr = myStr.replace(/(?!<A>)<D>/gi, '<A><D>');
alert (myStr);

This leads to compiling error.

var myStr = "<A><D><D>";
myStr = myStr.replace(/(?<!<A>)<D>/gi, '<A><D>');
alert (myStr);

Thank you for your comments!

@surfactant, can you clarify the context that you’re running this in? Based on your previous posts I assumed you were talking about a Userscript in the toolbox but your example works fine there for me.

  • Carey

Hi @careyh Thank you for your reply!

Nothing special about the context.

Simply open a file in Komodo > copy an existing script in the toolbox sidebar and empty it > paste the code snippet > save and close > run it

image

image

Yeesh, I read your first post wrong.

People using regex should know about “ (?!<A>) ” and “ (?<!<A>) ”.

I wouldn’t say this is a true statement. Look behind assertions weren’t supported in JS until recently it looks like. May not have even been added to the Mozilla JS interpreter until 2019? Not sure.

Any way, we’re running on Mozilla under the hood and an out dated version so look behind assertions won’t be supported in any JS running within Komodo I’m afraid.

To answer your possible next question: no, we won’t likely fix it. This should clarify why:

Nice find though!

Hi @careyh Thank you for your information! Let me add a temporary look-behind mark to get the work done.

Komodo is great for my current workflow of tweaking html files. But to speak frankly, it’s difficult to find enough official help information sometimes.

I wonder what’s the industry-standard tool for handling large amount of html files. I mean something like Microsoft Word with VBA for doc files. Not sure whether here is the right place for such a question.

Thanks again!

This sounds like a new topic. If you’d like to dig into that, lets do it in a new thread.

  • Carey
1 Like