Community
    • Login

    Batch replacing questions

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 420 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Sanc TuaryS
      Sanc Tuary
      last edited by

      Hello,

      I am trying to batch replace through multiple files a certain line. But while usually it’s easy with the Find in Files interface , in this case i’m puzzled as the line i want to replace is not always exactly the same : By example i want to replace that line
      blablabla = number
      by
      blablabla = 0

      My problem there is that “number” in the blablabla = is not always the same through all the files, but i need all of them to be = 0 in the end result, so i searched a bit and noticed some people mentionning “wildcard” and suggesting to look into “extended” and “regular expression” that you can tick in the bottom of the “Find in Files” box.

      So searching the online manual i ran into
      https://npp-user-manual.org/docs/searching/#extended-search-mode
      and
      https://npp-user-manual.org/docs/searching/#regular-expressions
      that does not mean anything to me as unfortunately it seems wrote for people that already know those controls and how to use and code them (and as those provide no example of each controls figuring it out on my own … well ) .

      So please, anyone can help me in my problem ?

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Sanc Tuary
        last edited by Alan Kilborn

        @Sanc-Tuary said in Batch replacing questions:

        it seems wrote for people that already know those controls and how to use and code them

        Well, kind of.

        But it is a big topic not just belonging to Notepad++, so the manual doesn’t attempt to reinvent the wheel…

        First, forget “Extended” mode – it won’t help. “Regular expression” land is where you want to be.

        You might be interested in the \d regular expression…that one finds a “digit”, i.e., 0-9. So:

        Find: blablabla = \d
        Search mode: Regular expression

        This would match blablabla = 4 or blablabla = 7 or etc.

        But it would not match blablabla = 24 exactly because that is two digits. It would match that as blablabla = 2 which isn’t what you want.

        So maybe switch to:

        Find: blablabla = \d+
        Search mode: Regular expression

        which would match blablabla = 24 or blablabla = 357 or etc.

        But maybe “number” in your question could be a negative number, or a positive number with a leading +, or a floating point number, or one in exponential notation…

        And whew, that got complicated fast, didn’t it?

        There are some good references HERE and one of them will lead directly HERE which is (or could be) more specific to your problem.

        Sanc TuaryS 1 Reply Last reply Reply Quote 2
        • Sanc TuaryS
          Sanc Tuary @Alan Kilborn
          last edited by

          @Alan-Kilborn
          Thank you very much, your examples really helped, the \d+ and how / where to use it solved my problem.

          Alan KilbornA 1 Reply Last reply Reply Quote 2
          • Alan KilbornA
            Alan Kilborn @Sanc Tuary
            last edited by

            @Sanc-Tuary said in Batch replacing questions:

            the \d+ and how / where to use it solved my problem

            I caught you a fish today. Tomorrow, catch your own by reading some of the references cited above.

            1 Reply Last reply Reply Quote 1
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors