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

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

Expand Messages
  • flo.gehrke
    Jun 17, 2013
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, Ian NTnerd <indiamcq@...> wrote:
      > 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.


      Yes, I think you are right. I was misled by those 54 ^!Replace lines in message #23877. Only today, I see that there seems to be no difference between single characters and 2-character-sequences.

      So why the heck does rickah make it three replacements: 'bJ' -> 'bS', 'b' -> 'b', and 'J' -> 'S' if the result is always the same? Also why 'KY' -> 'cF', 'K' -> 'c', and 'Y' -> 'F' etc...?

      Unfortunately, the only one who could answer this has made himself scarce. So the job is much easier, indeed.

      Obviously, we have to add 'D' -> 'f'.

      Another idea is to store the search and replace characters in a LIST.TXT file as follows:


      Among the search characters, the backslash is the only metacharacter that must be escaped: '\\'.

      The clip will load and convert this list into an array %Char%:

      ^!SetScreenUpdate Off
      ^!SetClipboard ^$GetFileText(^$GetDocumentPath$LIST.TXT)$
      ^!SetClipboard ^$StrReplace((\||\r\n);»;^$GetClipboard$;RA)$
      ^!SetListDelimiter »
      ^!SetArray %Char%=^$GetClipboard$
      ^!Set %i%=0

      ^!Inc %i%
      ^!If ^%i% > ^%Char0% Out
      ^!Set %Search%=^%Char^%i%%
      ^!Inc %i%
      ^!Set %RepWith%=^%Char^%i%%
      ^!Replace "(?<!\|)^%Search%" >> "|^%RepWith%" WARS
      ^!Goto Loop

      ^!Replace "|" >> "" WATS

      Tested with NT Pro 7.1.

      > I still think the before and after data strings are inconsistent
      > with the supplied change values.

      Yes, I agree with you. In the 54 ^!Replace commands, for example, 'A' is replaced with 'H' and not with 'h' as in the sample.

    • Show all 19 messages in this topic