random replace string for a limited amout of accourenses
-
Hi,
I have multiple files and I want to replace a certain word randomly in a string a limited amount of times.
The replace would have to search the files randomly and then replace the first 20 accourensesFor example if every line of every file would be in a database, I would need the command : update table set continut = REPLACE(continut, ‘word1’, ‘word’) order by rand limit 20
Thanks
-
Search-and-replace cannot randomize the list of files to search. And search-and-replace doesn’t have a counter that would work exactly like you showed (you can tell it to repeat part of the same regex N times, so it can count to some extent… but that’s counting within a single match, not counting and only doing a replacement for the first N matches). So you would have to manually pick your “random file” and then do the search/replace once in that file; then do that again N times.
The way you described it, it sounds like a programming challenge, not a text editor feature. And the purpose of this forum is to help each other use the existing features of Notepad++ to the best of its ability, not do other people’s programming for them.
If you want to solve it in programming, you could type the code to do that in Notepad++, which is one of its primary purposes. And if you wanted to, you could use one of the scripting plugins, like PythonScript, where the script would run on the files that are opened in Notepad++… but even then, it’s still essentially a programming task, and we are not a programming forum.