Giter VIP home page Giter VIP logo

Comments (3)

daddel80 avatar daddel80 commented on September 21, 2024 1

Hi andry91,

I had a second look at the issue and saw the error you were facing. In one of your if statements, the condition was incomplete and this was leading to misbehavior with the size of REPLACETO. I corrected this, and now it works.

The corrected expression:

1,"^([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+)(?:\\|([^\\r\\n\\|]+))?)?)?","init({DESTDIR="""",REPLACETO=""""}); if CAP1 ~= nil and string.sub(CAP1,1,3) == ""#> "" then DESTDIR=string.match(string.sub(CAP1,4,-1),""^(.+)\\\\"") elseif CAP1 ~= nil and string.sub(CAP1,1,1) ~= ""#"" and string.len(DESTDIR)>0 and CAP2 ~= nil then REPLACETO=DESTDIR..""\\\\|""..CAP2 end; cond(CAP1 ~= nil and CAP2 ~= nil and string.len(CAP1) and string.len(CAP2) and string.sub(CAP1,1,1) ~= ""#"" and string.len(REPLACETO) > 0, REPLACETO)",0,0,1,0,1

I have added a new version, 3.0.1.13, with a fix for the special characters in CAP. You can just copy and paste the entry above directly into the list with that version.

from notepadpp-multireplace.

andry81 avatar andry81 commented on September 21, 2024 1

string.len(...) > 0

https://www.lua.org/pil/2.2.html

Beware that, unlike some other scripting languages, Lua considers both zero and the empty string as true in conditional tests.

Just wow. 🤦

from notepadpp-multireplace.

daddel80 avatar daddel80 commented on September 21, 2024

Hi andry81,

I gave the regex a little update to make it shorter. The steps are the following.

  1. Check CAP1 for the # sign. Depending on the sign and line number, it replaces the line.
  2. Store the directory without any leading signs.

1,"^([^\\r\\n\\|]+)(?:\\|(.+))?$","init({DESTDIR=""""}); cond(string.sub(CAP1, 1, 1) ~= ""#"" and LINE ~= 1, DESTDIR..""|""..""$2""); if string.sub(CAP1, 1, 1) == ""#"" then DESTDIR=string.sub(CAP1,4,-1) end; ",0,0,1,0,1

PS: I used $2 here instead of CAP2 because there was a bug that just dropped the Parentheses . Since no content validation or editing is required at this point, it just fits here. It is a workaround. I will try to fix this and will overwrite release 3.0.0.12 which has been published a couple of days ago.

from notepadpp-multireplace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.