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

23881Re: [Clip] Re: alphanumeric character transcoding, by ones and pairs

Expand Messages
  • Ian NTnerd
    Jun 16 7:28 PM
    • 0 Attachment
      Flo,

      I don't think you need to split first. Just extend your initial idea so
      that the replacement that has two characters has a | inserted between
      the characters. Then your first RE replace works fine.

      So adding in these few lines before the replace happens but after the
      ^%ReplaceWith% is created.
      ^!If ^$StrSize("^%ReplaceWith%")$ = 2 addchar ELSE noadd
      :addchar
      ^!Set
      %ReplaceWith%=^$StrCopyLeft("^%ReplaceWith%";1)$|^$StrCopyRight("^%ReplaceWith%";1)$

      :noadd

      That gets me better results. I still think the before and after data
      strings are inconsistent with the supplied change values.

      I really appreciate what I learn from your RE.

      Ian

      On 14/06/2013 9:54 PM, flo.gehrke wrote:
      >
      > --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com>,
      > Ian NTnerd <indiamcq@...> wrote:
      > >
      > > Flo,
      > >
      > > Still has bugs see bottom (...)
      >
      > Ian,
      >
      > Yes, you are right. I've been quite certain that my "basic idea" would
      > get across more difficulties when regarding the complete list of
      > characters.
      >
      > Probably, we cannot avoid to first split the target string into valid
      > characters and sequences. Just to select a few of them...
      >
      > ; Assign all valid characters/sequences to %List%
      > ^!SetArray
      > %List%=bJ;dD;kY;KY;mD;mJ;pJ;PJ;SJ;sJ;a;A;b;B;c;d;E;e;F;f;g;h;H;o
      > ^!Set %i%=1
      > ; Split target string into valid characters/sequences
      > ^!Replace "(?<!\|)^%List^%i%%(?!\|)" >> "|$0" WARS
      > ^!Inc %i%
      > ^!If ^%i% > ^%List0% ContinueWith...
      > ^!Goto Split
      >
      > Now it's easier to match valid characters/sequences and to protect
      > them against getting replaced another time. The loop could be now...
      >
      > :Loop
      > ^!Inc %i%
      > ^!If ^%i% > ^%Char0% Out
      > ^!Set %Search%=\|^%Char^%i%%\|
      > ^!Inc %i%
      > ^!Set %RepWith%=^%Char^%i%%
      > ^!Replace "^%Search%" >> "#^%RepWith%#" WARS
      > ^!Goto Loop
      >
      > :Out
      > ^!Replace "#" >> "" WATS
      >
      > Thus, a valid string like '|A|' will be replaced with '#H#' which
      > should protect it against getting replaced another time.
      >
      > Of course, this is still imperfect. For example we have to pay
      > attention to characters being used as metacharacters etc. But, in the
      > moment, I have to leave that task to you or anyone else who has the
      > time and patience to continue working on this...
      >
      > Regards,
      > Flo
      >
      >



      [Non-text portions of this message have been removed]
    • Show all 19 messages in this topic