Loading ...
Sorry, an error occurred while loading the content.

[Clip] Re: replace with RegExp

Expand Messages
  • Hugo
    ... I still advise you to explore the script-piece I sent you earlier, it does exactly what you need without regexp. Place it in the loop-part and perform the
    Message 1 of 42 , Oct 26, 2001
    • 0 Attachment
      ::ANDREW::


      I still advise you to explore the script-piece I sent you earlier, it
      does exactly what you need without regexp. Place it in the loop-part
      and perform the replace action with the array as you already were
      examining.

      "Open FILE | Do this and do that | SAVE -> Go to the next file"


      You have to be careful with regular expressions, it is hard to test a
      pattern...

      1.
      If your {Hyperlink} part of your document looks like the example you
      gave, you could try building a specific expression such as:

      \{HYPERLINK\s*\n\n.*}

      This will match all occurences of text-fragments that
      contain "{HYPERLINK", "a space", "two linebreaks", "any character(s)"
      untill the last occurence of "}" at the last scanned line.

      If there are other patterns to match you could try using Alternation
      ("this|that" - see HELP)...

      You could use this regexp in CTRL+D, but keep in mind this may fail
      if the expression is eating too much resources. (You found that out
      already).


      2.
      Alternatively you could try to widen the scope of your search a
      little. If you know for sure that there will be always the same texts
      in front and after the piece of text that you are looking for, you
      could try adding these parts to your regExp. If you do that, you
      limit the scope of the search (am I still making sense?).

      In your case you could use

      {_blank">}\{HYPERLINK\a*\quot;\}

      The part _blank will be replaced by just using \1 in your replace-
      pattern. Normally \2-\9 should work as well for everything between
      {}, but maybe the escaped {} screw things up here. So if you need to
      add something to your findterm afterward, you cannot surround it in
      {} here. Example: just type http: after the expression in both the
      find-field and the replace-field.

      3.
      Alternatively, I just thought of that now, you could get rid of all
      of your empty lines before you do the actual replacement. And maybe a
      simple construct would do fine then... You have to study your
      material first before you can get the rewards... There are dozens of
      ways to do what you want, try to be creative...


      Bye,

      Hugo
    • Hugo
      ... I still advise you to explore the script-piece I sent you earlier, it does exactly what you need without regexp. Place it in the loop-part and perform the
      Message 42 of 42 , Oct 26, 2001
      • 0 Attachment
        ::ANDREW::


        I still advise you to explore the script-piece I sent you earlier, it
        does exactly what you need without regexp. Place it in the loop-part
        and perform the replace action with the array as you already were
        examining.

        "Open FILE | Do this and do that | SAVE -> Go to the next file"


        You have to be careful with regular expressions, it is hard to test a
        pattern...

        1.
        If your {Hyperlink} part of your document looks like the example you
        gave, you could try building a specific expression such as:

        \{HYPERLINK\s*\n\n.*}

        This will match all occurences of text-fragments that
        contain "{HYPERLINK", "a space", "two linebreaks", "any character(s)"
        untill the last occurence of "}" at the last scanned line.

        If there are other patterns to match you could try using Alternation
        ("this|that" - see HELP)...

        You could use this regexp in CTRL+D, but keep in mind this may fail
        if the expression is eating too much resources. (You found that out
        already).


        2.
        Alternatively you could try to widen the scope of your search a
        little. If you know for sure that there will be always the same texts
        in front and after the piece of text that you are looking for, you
        could try adding these parts to your regExp. If you do that, you
        limit the scope of the search (am I still making sense?).

        In your case you could use

        {_blank">}\{HYPERLINK\a*\quot;\}

        The part _blank will be replaced by just using \1 in your replace-
        pattern. Normally \2-\9 should work as well for everything between
        {}, but maybe the escaped {} screw things up here. So if you need to
        add something to your findterm afterward, you cannot surround it in
        {} here. Example: just type http: after the expression in both the
        find-field and the replace-field.

        3.
        Alternatively, I just thought of that now, you could get rid of all
        of your empty lines before you do the actual replacement. And maybe a
        simple construct would do fine then... You have to study your
        material first before you can get the rewards... There are dozens of
        ways to do what you want, try to be creative...


        Bye,

        Hugo
      Your message has been successfully submitted and would be delivered to recipients shortly.