Menu

Editor.rereplace

Help
2015-10-08
2015-10-08
  • Leo Velthuis

    Leo Velthuis - 2015-10-08

    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!

     
  • Sasumner

    Sasumner - 2015-10-08

    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.

     
  • Leo Velthuis

    Leo Velthuis - 2015-10-08

    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!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.