Problem with Find and replace using Regex



  • 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



  • 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.


Log in to reply