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

Re: [Clip] Re: replace across line breaks in a Str?

Expand Messages
  • Stephen Gilbert
    Hi Hugo, Here s the cleanup function I have right now. (I m hoping the smart quote characters and such will survive via email) H= htmlify_special_chars
    Message 1 of 3 , Apr 1 6:41 AM
    • 0 Attachment
      Hi Hugo,

      Here's the "cleanup" function I have right now. (I'm hoping the smart
      quote characters and such will survive via email)

      H="htmlify_special_chars"
      ^!Set %foo%=^?[(T=W)Text]
      ; convert smart quote left
      ^!Set %foo%=^$StrReplace("�";""";^%foo%;False;False)$
      ; convert smart quote right
      ^!Set %foo%=^$StrReplace("�";""";^%foo%;False;False)$
      ; convert apostrophe
      ^!Set %foo%=^$StrReplace("�";"´";^%foo%;False;False)$
      ; convert angle brackets
      ^!Set %foo%=^$StrReplace(">";">";^%foo%;False;False)$
      ^!Set %foo%=^$StrReplace("<";"<";^%foo%;False;False)$
      ; convert emdash
      ^!Set %foo%=^$StrReplace("�";"—";^%foo%;False;False)$
      ^!Info ^%foo%

      Here's my "testing" text, which includes each special char:
      ==
      Why �hello� I�ve enjoyed being here!

      Here's a < sign and a > sign.

      Hello�how are you doing today?
      ==

      If I paste this into my clip, it does the right thing for the first
      line but then dumps the subsequent lines to the current document (!).

      Thoughts?
      Stephen

      --- Hugo Paulissen <hugopaulissen@...> wrote:
      >
      >
      > Hi sgilbert92,
      >
      > > But when I try to use StrReplace on the text block, the line breaks
      > > boggle it. Any suggestion besides the not-so-elegant approach of
      > > replacing all line breaks with QQQ or something, doing StrReplace
      > on
      > > the offending special characters, and then converting the QQQ's
      > back
      > > to line breaks?
      > >
      > > I'm good with ^!Replace, but that only works on active docs, right,
      > > not vars?
      >
      > That is correct - you could send your variable to a file and then do
      > the ^!Replace on that, but that may not be necessary...
      >
      > I am not sure what you mean with "the line breaks boggle it". Could
      > you send an example of your code?
      >
      > If I run this clip on your mail I get a block of text without line-
      > breaks...
      >
      > ^!Set %Temp1%=^$strReplace("this";"that";"^$getClipboard$";0;0)$
      > ^!Set %Temp2%=^$strReplace("Word";"MS WORD";"^%Temp1%";0;0)$
      > ^!Set %Temp3%=^$strReplace("^P";" ";"^%Temp2%;0;0)$
      > ^!INFO ^%Temp3%
      >
      > Regards,
      >
      > Hugo
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
    • Adrian/ Rosemary Worsfold
      What is the explanation for this faster method: ^!Set %Temp1%=^$strReplace( this ; that ; ^$getClipboard$ ;0;0)$ ^!Set %Temp2%=^$strReplace( Word ; MS
      Message 2 of 3 , Apr 1 11:44 AM
      • 0 Attachment
        What is the explanation for this faster method:

        ^!Set %Temp1%=^$strReplace("this";"that";"^$getClipboard$";0;0)$
        ^!Set %Temp2%=^$strReplace("Word";"MS WORD";"^%Temp1%";0;0)$
        ^!Set %Temp3%=^$strReplace("^P";" ";"^%Temp2%;0;0)$
        ^!Info [L]^%Temp3%

        Compared with this, which does the same but is slower:

        ^!SetScreenUpdate Off
        ^!Keyboard CTRL+A
        ^!Keyboard CTRL+C
        ^!Keyboard SHIFT+CTRL+V
        ^!Keyboard CTRL+A
        ^!Menu Modify/Lines/Compress
        ^!Menu Modify/Lines/Join Lines

        ^!Set %Block%=^$GetSelection$
        ^!Close DISCARD

        ^!SetScreenUpdate On
        ^!Info [L]^%Block%

        Adrian Worsfold

        http://www.pluralist.co.uk
      • Hugo Paulissen
        ... Hi Stephen, Adrian, Yes, maybe... Your function is okay, only change the square brackets into curly braces... ^!Set %foo%=^?{(T=W)Text} That works (has to
        Message 3 of 3 , Apr 1 12:43 PM
        • 0 Attachment
          >
          > If I paste this into my clip, it does the right thing for the first
          > line but then dumps the subsequent lines to the current document (!).
          >
          > Thoughts?

          Hi Stephen, Adrian,

          Yes, maybe... Your function is okay, only change the square brackets
          into curly braces...

          ^!Set %foo%=^?{(T=W)Text}

          That works (has to do with the sequence of processing instructions).But
          you don't need this, ^$GetClipboard$ works too (and you don't have to
          paste manually every time you run the clip...)

          Adrian, I understood that functions are always the quicker way of
          getting things done.

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