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