Search and Replace
-
Fellow Notepad++ Users,
Could you please help me with the following search-and-replace problem I am having?
I need to search and replace in different documents with a line like
<property name=“CarryWeight” value=“1”/>The value changes and can be any number and I want to rplace the value with a number of my choosing.
Here is the data I currently have (“before” data):
<property name="CarryWeight" value="1"/> <property name="CarryWeight" value="20"/> Here is how I would like that data to look (“after” data): <property name="CarryWeight" value="0"/> <property name="CarryWeight" value="0"/> I feel this is something thats doable but my last computer class was in 1972 and I don' remember Fortran covering this. :) Thanks -
Are you saying your doc has other “property name” sections, but you only want to change your value in those that have the name
CarryWeight? -
@Alan-Kilborn Yes. I could search and replace manually but three of the files have over 7000 lines of code.
-
What you want is to search and replace only between other text. We have a prior solution for that. See if you can follow the RECIPE for that, but for your specific data.
-
@Alan-Kilborn Thank you I’ll give a go.
-
@Alan-Kilborn said in Search and Replace:
What you want is to search and replace only between other text.
You may be right, but nothing in what @Claude-Martin originally showed, nor in the subsequent exchange between you, supports the need for selectively acting on
property name="CarryWeight"lines bound by specified higher level tags.My reading of the need leads me to think simple regex solutions should be satisfactory:
1) replace a specific group of nums with a specific num Fi: <property name="CarryWeight" value="(?:1|3|15|20)"/> Re: <property name="CarryWeight" value="PLACE_NEW_NUM_HERE"/> or 2) replace all nums with a specific num Fi: <property name="CarryWeight" value="\d+"/> Re: <property name="CarryWeight" value="PLACE_NEW_NUM_HERE"/> -
Yes, indeed, it may very well be the simpler case. I was fooled because so often these go the other way. :-)
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