Community
    • Login

    Replace text on certain lines only - Column Editor

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 2.4k Views 2 Watching
    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.
    • Mark LovickM Offline
      Mark Lovick
      last edited by

      I have a text file with approx 6000 lines
      The majority of the lines have a full string of text and I need to edit a two digit number to something else
      I can use column editor adn over type but this then puts whatever I type on every line including the ones without the original number. Is there a way of only replacing the number with the new on in lines that have it? I’d say 90% do have an entry to repace and 10% don’t

      1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones
        last edited by

        Using example data from another thread…

        Gui, Add, Button, x22 y150 w90 h20 , Button 1
        Gui, Add, Button, x22 y170 w90 h20 , Button 2
        Gui, Add, Button, x22 y190 w90 h20 , Button 3
        # dummy line, different than the rest
        Gui, Add, Button, x22 y210 w90 h20 , Button 4
        Gui, Add, Button, x22 y230 w90 h20 , Button 5
        Gui, Add, Button, x22 y250 w90 h20 , Button 6
        

        Assuming you wanted all the x22 replaced with x314, Search > Replace..., with ☑ Regular Expression

        • Find What = (?-is)\bx22\b
        • Replace with = x314

        Assuming you wanted all the various y### replaced with the same y2718,

        • Find What = (?-is)\by\d+\b
        • Replace with = y2718

        Assuming you wanted all the various y### replaced with a variety of y-numbers, depending mathematically or logically on the value of the original y###, you would use the PythonScript plugin and a variant of the script I showed in that other thread

        With no data examples given, we cannot tailor the response to your data.


        P.S. :
        (paraphrasing @guy038, the forum’s regex guru, who compiled these great regex resources, but hasn’t shared them in this thread yet):

        Here is a good starting point for NPP users unfamiliar with regular expression concepts and syntax:

        • http://docs.notepad-plus-plus.org/index.php/Regular_Expressions

        Modern Notepad++ (since v6.0) uses the Boost C++ Regex library, v1.55.0 (similar to the Perl Regular Common Expressions (PRCE), v5.8):

        • search syntax: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
        • replace syntax: http://www.boost.org/doc/libs/1_55_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

        Other sites with valuable regular expression information include:

        • http://perldoc.perl.org/perlre.html
        • http://www.regular-expressions.info
        • http://www.rexegg.com
        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors