Community
    • Login

    REGEX: Add something at the beginning of each line that does not contain the sign -

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 271 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.
    • Robin CruiseR
      Robin Cruise
      last edited by Robin Cruise

      I want to add something to the beginning of each line that does not contain the sign -

      My regex is not so good:

      FIND: ^(?!\-)
      REPLACE BY: ANYTHING

      1 Reply Last reply Reply Quote 0
      • Robin CruiseR
        Robin Cruise
        last edited by Robin Cruise

        Got it. There was no need for \ before -

        FIND: ^(?!-)
        REPLACE BY: ANYTHING

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

          So for future people that come along looking maybe for a solution to something, and seeing this post, I say: It has several pieces of misinformation.

          First, the “spec” was:

          add something to the beginning of each line that does not contain the sign -

          In fact, the regex supplied does not do this. What it does is: Add something to the beginning of each line that does not start with -.

          Second, the OP diagnosed a problem as being that:

          There was no need for \ before -

          In fact, the removal of \ did nothing to change the outcome of the replacement operation. - does not need to be “escaped” in the usage shown by the OP. While it was true that there was “no need”, it didn’t make the first regex not work. The two regexes supplied by the OP do exactly the same thing.

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