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

17158Re: [Clip] Regular expression replace upon a string variable - howto?

Expand Messages
  • Sheri
    Nov 30, 2007
    • 0 Attachment
      Flo wrote:
      > --- In ntb-clips@yahoogroups.com, buralex@... wrote:
      >
      >
      >> For now I'm just using a series of
      >> ^!set %newName%=^$StrReplace(":";"-";^%newName%;False;False)$
      >> one for each potential invalid character...
      >>
      >
      > Just another approach...
      >
      > Replacing invalid characters ": \ / $ ?" in "f:i\l/e$n?ame.html" that
      > is stored in a variable %newName%...
      >
      > ^!ClearVariable %ValidName%
      > ^!Set %newName%=f:i\l/e$n?ame.html
      > ^!Set %Position%=1
      >
      > :Loop
      > ^!Set %Proof%=^$StrCopy(^%newName%;^%Position%;1)$
      > ^!IfMatch "[:\\\/\$\?]" "^%Proof%" Next Else Skip
      > ^!Set %Proof%=^$StrReplace("^%Proof%";"-";^%Proof%;0;0)$
      > ^!Append %ValidName%=^%Proof%
      > ^!Inc %Position%
      > ^!If ^%Position%>^$StrSize(^%newName%)$ End
      > ^!Goto Loop
      >
      > :End
      > ^!Info The correct name is ^%ValidName%
      >
      > Regards,
      > Flo
      >
      >
      >
      That's very clever, Flo!

      Regards,
      Sheri
    • Show all 7 messages in this topic