Tapatalk

Search for hard return in string with findreplace

Search for hard return in string with findreplace

4
NewbieNewbie
4

    Nov 16, 2007#1

    In a script, I want to search for some text that has a hard return in it (DOS text file) and then delete it by replacing it with a null string "". The text is something like:

    changetype: add <--- hard return after 'add'
    loginDisabled:

    If I put the following line in a script, it doesn't work:

    UltraEdit.activeDocument.findReplace.replace("changetype: add
    loginDisabled: ","");

    If I use the ^p character to match the Hrt (like you can use in a normal find/replace), it doesn't work as well:

    UltraEdit.activeDocument.findReplace.replace("changetype: add^ploginDisabled: ","");

    Is it not possible to search for a string with hard returns or other control characters when using the findReplace command in a script?

    Thanks,

    Dan

    262
    MasterMaster
    262

      Nov 16, 2007#2

      I could reproduce the same reaction from UE as you described for the one line script.

      UltraEdit.activeDocument.findReplace.replace("changetype: add^ploginDisabled:","");


      but when I added some initializing to some of the findReplace options and the regular expression engine it worked ok. I haven't experimented with which option was needed from these:

      UltraEdit.ueReOn();
      UltraEdit.activeDocument.findReplace.regExp=false;
      UltraEdit.activeDocument.findReplace.replaceAll=false;
      UltraEdit.activeDocument.findReplace.replace("changetype: add^ploginDisabled:","");


      Go figure. I think it can't hurt to ensure all options are set as you need them without assuming they are set as needed.

      (And just to be sure: You also have a blank following the colon in loginDisabled: so there must be a blank in the data but I can't tell if this is true from your example).

      4
      NewbieNewbie
      4

        Nov 16, 2007#3

        Thanks. I'll add those options. Yes, there is a blank following the colon in the file I am working on.

        So it looks like you can embed the ^p, ^t, etc right in the text like you would if you were manually searching for it?

        Also, is there any way to get the script to pause and then continue after some user input? So I would like to start the script, have it search for some known text, then turn on select and pause while I move the cursor to the end of the text I want selected (since it changes) then when I hit enter the script continues doing what I have programmed it to do. Is this possible?

        Dan

        262
        MasterMaster
        262

          Nov 16, 2007#4

          I haven't experimented with changing cursor position in a document while a running script is paused by getString, getValue or messageBox. Open UE help and read about these script commands. If you experiment with these in your script, perhaps you can report back to us how it went ?!

          And yes: ^p, ^t, ^n can be used in script exactly like in normal search/replace.