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

Re: [Clip] A crazy Replace....

Expand Messages
  • buralex@gmail.com
    Hi absent The reason the replacement isn t working is that certain characters which appear in the text you want to replace with have to be escaped before you
    Message 1 of 11 , Mar 14, 2008
    • 0 Attachment
      Hi absent

      The reason the replacement isn't working is that certain characters
      which appear in the text you want to replace with have to be escaped
      before you can put them in a variable. eg. "<" and "&" must appear as
      "\<" and "\&"

      The easiest way to convert a string (of reasonable length - not sure
      what max is) to properly escaped text is to

      * open the Replace dialog,
      * turn on regular expression replacement,
      * select then copy the text you want "converted" then
      * paste it into the Find field of the Replace dialog.
      o It will get escaped properly.
      * now copy that entire string and paste it into your ^!replace line
      in your clip

      this should work. Here's a clip which illustrates the lines at each
      stage. Note yahoo will cause line-breaks in it.
      The clip has three ^!set lines - the last (the one that works will be
      the one executed)

      H="Hard to replace"
      ; Alec Burgess 2008-03-15
      ;Text to replace: <div lang="en">304599843 10</FONT> </P></TD>
      </TR></TBODY> </TABLE>< /DIV>

      ;Unescaped text (one line) <br><br><b>Business Administration - The Key
      Elemënts of</b><br><br> <br><br>Every Search Engine [SE] is different
      and they each have their own guidelines for what constitutes a pleasant
      and valuable site, & nbsp;but a common factor that they all tend to
      track and follow are link exchanges.<br> <br>Almost everything that you
      will peruse on the Internet on the Google Sandbox theory is conjecture,&
      nbsp;  pieced together from individual experiences and not from a
      widescale objective controlled experiment with hundreds of websites
      [something that would obviously aid in determining the nature of the
      Sandbox,   but is inherently impractical given the demand on
      resources].< br><br>The date for installation of a ERP¹/CRM¹ is not
      reduced to weeks,   as announced.   ERP¹ /CRM¹ is
      essentially consulting services,   delayed and costly as we
      know, & nbsp;and the installation date will continue the same as IT¹ is

      ;Escaped test \<br\>\<br\>\<b\>Business Administration - The Key
      Elemënts of\</b\>\<br\>\<br\>\r\n\<br\>\<br\>Every Search Engine \[SE\]
      is different and they each have their\r\nown guidelines for what
      constitutes a pleasant and valuable\r\nsite,\ \& nbsp;but a common
      factor that they all tend to track and\r\nfollow are link
      exchanges\.\<br\> \<br\>Almost everything that you will\r\nperuse on the
      Internet on the Google Sandbox theory is\r\nconjecture,\& nbsp;\ 
      pieced together from individual experiences and\r\nnot from a widescale
      objective controlled experiment with hundreds of\r\nwebsites \[something
      that would obviously aid in determining the nature\r\nof the
      Sandbox,\  \ but is inherently impractical given the\r\ndemand
      on resources\]\.\< br\>\<br\>The date for installation of a
      ERP¹/CRM¹\r\nis not reduced to weeks,\  \ as
      announced\.\  \ ERP¹ /CRM¹\r\nis essentially consulting
      services,\  \ delayed and costly as\r\nwe know,\ \&
      nbsp;and the installation date will continue the same\r\nas IT¹ is

      ; first test - simple replace
      ^!set %variable%="what the heck"

      ; second test - one line (not escaped) - this will fail due to "<"'s and
      "&"'s
      ^!set %variable%="<br><br><b>Business Administration - The Key Elemënts
      of</b><br><br> <br><br>Every Search Engine [SE] is different and they
      each have their own guidelines for what constitutes a pleasant and
      valuable site, & nbsp;but a common factor that they all tend to
      track and follow are link exchanges.<br> <br>Almost everything that you
      will peruse on the Internet on the Google Sandbox theory is conjecture,&
      nbsp;  pieced together from individual experiences and not from a
      widescale objective controlled experiment with hundreds of websites
      [something that would obviously aid in determining the nature of the
      Sandbox,   but is inherently impractical given the demand on
      resources].< br><br>The date for installation of a ERP¹/CRM¹ is not
      reduced to weeks,   as announced.   ERP¹ /CRM¹ is
      essentially consulting services,   delayed and costly as we
      know, & nbsp;and the installation date will continue the same as
      IT¹ is"

      ; third test - one line escaped - this will work.
      ^!set %variable%="\<br\>\<br\>\<b\>Business Administration - The Key
      Elemënts of\</b\>\<br\>\<br\>\r\n\<br\>\<br\>Every Search Engine \[SE\]
      is different and they each have their\r\nown guidelines for what
      constitutes a pleasant and valuable\r\nsite,\ \& nbsp;but a common
      factor that they all tend to track and\r\nfollow are link
      exchanges\.\<br\> \<br\>Almost everything that you will\r\nperuse on the
      Internet on the Google Sandbox theory is\r\nconjecture,\& nbsp;\ 
      pieced together from individual experiences and\r\nnot from a widescale
      objective controlled experiment with hundreds of\r\nwebsites \[something
      that would obviously aid in determining the nature\r\nof the
      Sandbox,\  \ but is inherently impractical given the\r\ndemand
      on resources\]\.\< br\>\<br\>The date for installation of a
      ERP¹/CRM¹\r\nis not reduced to weeks,\  \ as
      announced\.\  \ ERP¹ /CRM¹\r\nis essentially consulting
      services,\  \ delayed and costly as\r\nwe know,\ \&
      nbsp;and the installation date will continue the same\r\nas IT¹ is"

      ^!Replace "30459984310" >> "^%variable%" rwais


      abetsent said the following on 2008/03/14 21:58:
      > Friends,
      >
      > I am not yet crazy, I think...
      >
      > See this text:
      >
      > <div lang="en">30459984310</FONT></P></TD></TR></TBODY></TABLE></DIV>
      >
      > For hours, I tried everything to replace:
      >
      > ^!Replace "30459984310" >> "^%variable%" tiws
      >
      > and do not replaced, even using a lot of variations.
      >
      > ^%variable% are an English text, .txt, see in the end of this post.
      >
      > But if I try
      >
      > ^!Replace "30459984310" >> "vvvvvvvvvvvvvvvvvv" tiws
      >
      > he work 100%.
      >
      > Really, I do not understand.
      >
      > Thanks, friends.
      >
      > The ^%variable% text is the following:
      >
      > <br><br><b>Business Administration - The Key Elemënts of</b><br><br>
      > <br><br>Every Search Engine [SE] is different and they each have their
      > own guidelines for what constitutes a pleasant and valuable
      > site,  but a common factor that they all tend to track and
      > follow are link exchanges.<br><br>Almost everything that you will
      > peruse on the Internet on the Google Sandbox theory is
      > conjecture,  pieced together from individual experiences and
      > not from a widescale objective controlled experiment with hundreds of
      > websites [something that would obviously aid in determining the nature
      > of the Sandbox,  but is inherently impractical given the
      > demand on resources].<br><br>The date for installation of a ERP¹/CRM¹
      > is not reduced to weeks,  as announced.  ERP¹/CRM¹
      > is essentially consulting services,  delayed and costly as
      > we know,  and the installation date will continue the same
      > as IT¹ is
      >
      >
      >
      >

      Regards ... Alec -- buralex-gmail
      --



      [Non-text portions of this message have been removed]
    • Flo
      ... Alec wrote... ... IMHO, that isn t necessary in general. The escape is needed only (1) on the left side (find side) of the Replace command and (2) if the
      Message 2 of 11 , Mar 15, 2008
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, buralex@... wrote:

        Alec wrote...

        > The reason the replacement isn't working is that certain
        > characters which appear in the text you want to replace with
        > have to be escaped before you can put them in a variable. eg.
        > "<" and "&" must appear as "\<" and "\&"

        IMHO, that isn't necessary in general. The escape \ is needed only
        (1) on the left side (find side) of the Replace command and (2) if
        the find string contains characters that could be interpreted as
        metacharacters.

        Test it with this text...

        "Replace the following string 30459984310 with..."

        ...and the following clip:

        ^!Set %ReplaceStr%="<div as</DIV>"
        ^!Replace "30459984310" >> "^%ReplaceStr%" AWS

        For me, also abetsent's replacement works fine if all CR/NL in the
        replacement string (on the right) are replaced with ^%NL% as proposed
        by Alan C.


        Flo
         
      • Axel Berger
        ... Where can I read more about that? I m quite sure that I have successfully used
        Message 3 of 11 , Mar 15, 2008
        • 0 Attachment
          buralex@... wrote:
          > certain characters
          > which appear in the text you want to replace with have to be escaped
          > before you can put them in a variable.

          Where can I read more about that? I'm quite sure that I have
          successfully used "<" in a variable more than once.

          Axel
        • hsavage
          ... Axel, All, Everyone jumped to the conclusion that the original poster was seeking a regex solution, he was not, specifically. Here s his clip command;
          Message 4 of 11 , Mar 15, 2008
          • 0 Attachment
            Axel Berger wrote:
            > buralex@... wrote:
            >> certain characters
            >> which appear in the text you want to replace with have to be escaped
            >> before you can put them in a variable.
            >
            > Where can I read more about that? I'm quite sure that I have
            > successfully used "<" in a variable more than once.
            >
            > Axel

            Axel, All,

            Everyone jumped to the conclusion that the original poster was seeking a
            regex solution, he was not, specifically. Here's his clip command;
            ^!Replace "30459984310" >> "^%variable%" TIWS; no regex, no need to
            escape anything in the replace variable, and yes, the 3rd line is
            superfluous in the clip below.

            ^!Open c:\a_provis\prov3.htm
            ^!Find 30059984333 tiws
            ^!Set %pro%=^$GetSelection$
            ^!InsertFile c:\a_provis\prov4.htm

            ·············································
            ºvº SL_075 created_2008.03.15_00.23.14

            Great Truths Children Have Learned:
            • You can't trust dogs to watch your food.
            € hrs € hsavage € pobox € com
          • buralex@gmail.com
            ... I don t know about everyone but I certainly did and realized my error when I saw others posts. my bad! :-) ... ^!Set %pro%=^$GetSelection$ - that s the
            Message 5 of 11 , Mar 15, 2008
            • 0 Attachment
              hsavage <hsavage@...> said on Mar 15, 2008 15:47 -0400 (in part):
              > Everyone jumped to the conclusion that the original poster was seeking a
              > regex solution, he was not, specifically.
              I don't know about "everyone" but I certainly did and realized my error
              when I saw others posts.
              my bad! :-)
              > Here's his clip command;
              > ^!Replace "30459984310" >> "^%variable%" TIWS; no regex, no need to
              > escape anything in the replace variable, and yes, the 3rd line is
              > superfluous in the clip below.
              ^!Set %pro%=^$GetSelection$ - that's the kind of thing I do too. create
              intermediate variables while working out/debugging a solution and then
              forget to clean out all the "cruft" when done.
              >
              > ^!Open c:\a_provis\prov3.htm
              > ^!Find 30059984333 tiws
              > ^!Set %pro%=^$GetSelection$
              > ^!InsertFile c:\a_provis\prov4.htm
              As the the problem was later redefined this is a *much* preferable
              solution. Sorry for confusing things. While not needed here, the "trick"
              of posting something into the Find field while Regexp is turned on to
              get it automatically escaped can be very useful sometimes.

              Regards ... Alec -- buralex-gmail
              --



              [Non-text portions of this message have been removed]
            • abetsent
              All friends, Thanks! Appears to me that if you have a text with several strange codes, will be better to Find and later InsertFile, instead of Replace. With
              Message 6 of 11 , Mar 15, 2008
              • 0 Attachment
                All friends, Thanks!

                Appears to me that if you have a text with several strange codes, will
                be better to Find and later InsertFile, instead of Replace.

                With InsertFile do not matter the content of the text, as in the Replace.

                So, use Replace for simple texts and InsertFile for complex texts.

                Yes, I forget to delete the third line, used only for debug.

                Thanks again to all gurus.



                --- In ntb-clips@yahoogroups.com, "Alan C" <acummingsus@...> wrote:
                >
                > What does:
                >
                > ^!Toolbar "new document"
                > ^!Insert "^%variable%"
                >
                > that do when you try it?
                >
                > Does it insert all, or a part of, your text?
                >
                > (I'm wondering if you might need ^%NL%
                >
                > at line breaks, if any exist). | Alan.
                >
                > On Fri, Mar 14, 2008 at 6:58 PM, abetsent <backup2abet@...> wrote:
                >
                > > Friends,
                > >
                > > I am not yet crazy, I think...
                > >
                > > See this text:
                > >
                > > <div lang="en">30459984310</FONT></P></TD></TR></TBODY></TABLE></DIV>
                > >
                > > For hours, I tried everything to replace:
                > >
                > > ^!Replace "30459984310" >> "^%variable%" tiws
                > >
                > > and do not replaced, even using a lot of variations.
                > >
                > > ^%variable% are an English text, .txt, see in the end of this post.
                > >
                > > But if I try
                > >
                > > ^!Replace "30459984310" >> "vvvvvvvvvvvvvvvvvv" tiws
                > >
                > > he work 100%.
                > >
                > > Really, I do not understand.
                > >
                > > Thanks, friends.
                > >
                > > The ^%variable% text is the following:
                > >
                > > <br><br><b>Business Administration - The Key Elemënts of</b><br><br>
                > > <br><br>Every Search Engine [SE] is different and they each have their
                > > own guidelines for what constitutes a pleasant and valuable
                > > site,  but a common factor that they all tend to track and
                > > follow are link exchanges.<br><br>Almost everything that you will
                > > peruse on the Internet on the Google Sandbox theory is
                > > conjecture,  pieced together from individual experiences and
                > > not from a widescale objective controlled experiment with hundreds of
                > > websites [something that would obviously aid in determining the nature
                > > of the Sandbox,  but is inherently impractical given the
                > > demand on resources].<br><br>The date for installation of a ERP¹/CRM¹
                > > is not reduced to weeks,  as announced.  ERP¹/CRM¹
                > > is essentially consulting services,  delayed and costly as
                > > we know,  and the installation date will continue the same
                > > as IT¹ is
                >
                >
                > [Non-text portions of this message have been removed]
                >
              • Axel Berger
                ... One more question: Is there a size limit for variables and/or for search and Replace fields in ^!Replace? I know there is one, and rather a small one too,
                Message 7 of 11 , Mar 15, 2008
                • 0 Attachment
                  abetsent wrote:
                  > use Replace for simple texts and InsertFile for complex texts.

                  One more question:
                  Is there a size limit for variables and/or for search and Replace fields
                  in ^!Replace?

                  I know there is one, and rather a small one too, in the Replace Menu
                  item, and it has already bitten me several times.

                  Axel
                • Axel Berger
                  ... It was a genuine question, not trying to look clever. I ve rarely or never used those constructs that rely on things being highlighted after a command and
                  Message 8 of 11 , Mar 15, 2008
                  • 0 Attachment
                    buralex@... wrote:
                    > ^!Set %pro%=^$GetSelection$ - that's the kind of thing I do too.
                    > Create intermediate variables while working out/debugging a solution

                    It was a genuine question, not trying to look clever. I've rarely or
                    never used those constructs that rely on things being highlighted after
                    a command and find that sort of thing to be rather confusing. A
                    ^!Replace or a ^$StrReplace()$ is more straightforward imho.

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