Skip to content

Problem with regex including colon  #3

Open
@ghetolay

Description

@ghetolay

Hi,

I was not able to change a default value from a minified javascript library, output was like :

{autoScrollSize:!0,autoUpdate:!0,debug:!1,disableBodyScroll:!1,duration:200,ignoreMobile:!1,ignoreOverlay:!1,scrollStep:30,showArrows:!1,stepScrolling:!0,scrollx:null,scrolly:null,onDestroy:null,onInit:null,onScroll:null,onUpdate:null}

and I wanted to change the default value of ignoreOverlay to !0with that call :

.pipe(replace( {regex:'ignoreOverlay:([!01])', replace:'!0'} ))

So I'm not really understanding why you use 2 different RegExp() constructor based on the value returned by isWord() but using the RegExp() with boundary word (\b) was in fault. So I changed isWord() accordingly :

function isWord(str) {
  if ((str.indexOf(' ') === -1) &&
      (str.indexOf('.') === -1) &&
      (str.indexOf(',') === -1) &&
      (str.indexOf('=') === -1) &&
      (str.indexOf(';') === -1) &&
      (str.indexOf(':') === -1)) {      //<-- Added colon
    return true;
  }
  return false;
}

and now it works but I'm not sure if it's the good solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions