I'm trying to use the rereplace function to change some files. But sometimes I only need to replace things once.
I tried different ways to use the maxCount option. But none of them seem to work.
This is the format I found online:
Editor.rereplace(search, replace[, flags[, startPosition[, endPosition[, maxCount]]]])
These are the codes I've tried:
editor.rereplace(u"*\n*C", u"*C", maxCount=1)
editor.rereplace(u"*\n*C", u"*C", 1)
editor.rereplace(u"*\n*C", u"*C", "1")
The replacing works fine. But it does it to all items and not just the first one.
I was hoping someone could tell me what I'm doing from.
Thanks in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I believe that if you want to use the maxCount argument of .rereplace(), you must also specify flags, startPosition, and endPosition. Thus, begin experimenting with a call to .rereplace() that has six parameters. I think you will then have better luck.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm trying to use the rereplace function to change some files. But sometimes I only need to replace things once.
I tried different ways to use the maxCount option. But none of them seem to work.
This is the format I found online:
Editor.rereplace(search, replace[, flags[, startPosition[, endPosition[, maxCount]]]])
These are the codes I've tried:
editor.rereplace(u"*\n*C", u"*C", maxCount=1)
editor.rereplace(u"*\n*C", u"*C", 1)
editor.rereplace(u"*\n*C", u"*C", "1")
The replacing works fine. But it does it to all items and not just the first one.
I was hoping someone could tell me what I'm doing from.
Thanks in advance!
Leo,
I believe that if you want to use the maxCount argument of .rereplace(), you must also specify flags, startPosition, and endPosition. Thus, begin experimenting with a call to .rereplace() that has six parameters. I think you will then have better luck.
Hey,
Thanks a lot! You were right I changed it to:
editor.rereplace(u"*\n*C", u"*C", 0, 0, 10000, 1)
And now it works as intended!
Thanks again!