Community
    • Login

    Problem with Find and replace using Regex

    Scheduled Pinned Locked Moved General Discussion
    regexsearch & replace
    2 Posts 1 Posters 2.0k 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.
    • Noel WorlandN
      Noel Worland
      last edited by

      Hi All,
      Please bear with me as I’m a total newbie to regex syntax.
      I have a text file which I’m trying to do a find and replace on using regex because normal find and replace would take too long. The text file is over 1 million lines long. My regex search successfully finds what I need. My replace successfully replaces it. But the problem is - after clicking “replace all” the text file is now over 2 million lines. I think it has something to do with the replace regex syntax
      Example of lines I’m searching for - model “AMURRY 150327 DR PIPE UG”

      My Regex find - model\s"(AMURRY|CKB|CLAYDEN|DARACON|DOWNER|FREDON|FULTON HOGAN|FH DWC|FUSION|GFIS|HUSKY|LEND LEASE|M AND P|MURPHY|OLYMPIC|ROBSON|SAFEGATE|SAGEGATE|SPANTECH|STOWE|WILKEN) \d+\s

      My regex replace - model "$`

      Can anyone tell me why it is adding all the extra lines. Or suggest a better way? Thanks in advance

      1 Reply Last reply Reply Quote 0
      • Noel WorlandN
        Noel Worland
        last edited by

        Hi I found my own solution -
        My Regex find -
        (model\s"(AMURRY|CKB|CLAYDEN|DARACON|DOWNER|FREDON|FULTON HOGAN|FH DWC|FUSION|GFIS|HUSKY|LEND LEASE|M AND P|MURPHY|OLYMPIC|ROBSON|SAFEGATE|SAGEGATE|SPANTECH|STOWE|WILKEN) \d+\s)(.*)

        My regex replace - model "\3

        it now does not add the million lines of text.

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