mass replace diffrent text in file
i have a large text file where i would like to replace an extension with regex, help me
Z site:com Y site:fr X site:uk
Z site:pl Y site:pl X site:pl
where i would like to replace an extension with regex,
Using the Replace function we have
As this is a regex the “search mode” needs to be regular expression. Wrap around can be ticked.
You can either hit the “Replace button” to see each change, or the Replace All button to do the entire file in 1 go.
PS this assumes there is ONLY 1
:in the line, immediately before the “extension” you wish to change. As you haven’t really shown us “real” data this is assumed.
PS this assumes there is ONLY 1 : in the line
As a matter of interest the easy way to determine if ANY line has more than 1
:is to run a regex using the “Find” function and using the “Count” button.
So the regex could be (my version, there are many ways to do this)
Again as a regex the search mode must be “regular expression” and you should either have the cursor at top of file, or make sure “wrap around” is ticked so that it can check the entire content of the file. After clicking the “Count” button the bottom of the “Find” window will show you:
“Count: xx matches from caret to end of file” (my setting was not “wrap around”) or “in entire file” and xx is the number 0 or more.
Maybe the OP wants to replace only
:, which is easy to do, but why bother unless the OP clarifies the need.
Plus OP is starting to become a “regex taker” and should be requested to show what he’s tried and failed with, before receiving additional help.
Again, fairly easy :
Like @terry-r, I assume just one
:per line, followed with a country identifier, ending the current line
The search regex tries to match the greatest range, non empty, of lowercase letters, which is immediately preceded with a colon
You must use the
Replace Allbutton, exclusively, if your N++ version is prior the
v7.9.1version. Else, the
Replacebutton can be used as well ;-))
Hi, @terry-r and All,
To count all the lines which contain, at least, two
:signs, this regex should be enough :
Indeed, we do not have to care about text before the first colon and text after the second colon ;-))
And, if you click on the
Find Nextbutton it matches all the range of characters between these two colons, included !
thanks everyone for your help, i’ve got how to make this work