Massive list and massive search and replace?
-
this script is FANTASTIC.
i do have a question though- in the final output it prints how many replacements were made, but is there any way to see what the actual replacements were?
looking into the code i see
“”" if self.num_repl_made_in_this_file > 0:
self.print('replacing "{fw}" with "{rw}" {n} times'.format( fw=find_what, rw=replace_with, n=self.num_repl_made_in_this_file)) """but i dont see where that would get printed- it doesnt show up in the python console either
again huge thanks for this one
-
@nerdyone255 said :
this script is FANTASTIC.
Well…glad you like it.
but i dont see where that would get printed- it doesnt show up in the python console either
The
self.print()function calls are really meant as debug helpers while testing the script. Thus, in the version of the script above, they don’t do anything because thedebugvariable is set to False. If you change the0to a1in this line:self.debug = True if 0 else Falseor simply change it to:
self.debug = Truethen the output of the self.print() calls will go to the PythonScript console window. You’ll see the output you indicated you were interested, plus output from other things that happen while the script is running.
-
@Alan-Kilborn perfect!
-
A Alan Kilborn referenced this topic on
-
Thanks Alan, it work perfectly, Except one specially for me. Appreciate your help if possible:
I want to find only within word boundary.
For example:
Sentence: You are eating apple. The tree have a lot of apples. all the apples is green.
apple->cherry
apples->cherries
Hence, how can I add in a code to made it change only words start or end a transition from space to non-space character (space, common, dot, quote marks, questions mark…).
thanks in advance
Yurble -
@Yurble-Vương said in Massive list and massive search and replace?:
how can I add in a code to made it change only words start or end a transition from space to non-space character
You can use
\bin the regular expression to insist upon a word boundary; example:\bapplewill matchhave an apple todaybut will not matchhave a crabapple today. -
This post is deleted! -
Sorry to ask and bother you. I tried to edit your py code as below, but it seems to be a wrong code. Could you advise how to correct:
Not work:
# FINALLY, the actual replacement! editor.rereplace('\b'+find_what+'\b', replace_with)Not work 2:
# FINALLY, the actual replacement! editor.rereplace(r'\b'+find_what+'\b', replace_with) -
@Yurble-Vương said :
Not work 2
This should work:
editor.rereplace(r'\b'+find_what+r'\b', replace_with)I like how you showed initiative in trying to solve the problem yourself…and you had the right idea, you just didn’t take it far enough.
-
Many thanks for help
-
A Alan Kilborn referenced this topic on
-
Alan it’s fantastic!
At this part:
is it possible to enter more files into the filter list?