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

18559Replace text case and number replacements in clip using PowerPro regex

Expand Messages
  • Sheri
    Oct 18, 2008
      This clip replaces the text case of all occurrences of a line which
      follows one consisting of "Title::" and inserts a sequential number in
      front of it. The Powerpro replacement string of "$# $T0" says replace
      with "next sequential number, space, whole match ($0) in title case."
      On my slow machine it finishes in one or two seconds on approx 12000
      lines with approx 300 hits.

      ^!Select All
      ^!SetClipboard ^$GetSelection$
      ^!Set %ppropath%=^$GetShort("C:\Program Files\Powerpro\Powerpro.exe")$
      ;powerpro must be running
      ^!IfAppOpen "Powerpro*" Skip_3 ELSE Next
      ^!Set %closeit%=1
      ^!Shell ^%ppropath% Empty.pcf
      ^!Delay 10
      ^!ShellWait ^%ppropath% *Script global regex_status regex_count
      ;long line follows
      ^!ShellWait ^%ppropath%
      clip.set(regex.pcrereplace(?"(?mi)^Title::\R\K.++", clip.get, ?"$# $T0"))
      ;end long line
      ^!Menu Edit/Paste
      ^!Jump Doc_Start
      ;close Powerpro if this clip started it
      ^!IfTrue ^%closeit% Next Else Skip
      ^!ShellWait ^%ppropath% Shutdown.Powerpro("noconfirm")
      ^!ClearVariable %closeit%
      ;end of clip