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

414Re: [NTS] Changing Case with Regex

Expand Messages
  • Sheri
    Jun 8, 2008
      John Shotsky wrote:
      > I am processing fairly large (~1M) text files, in which certain words
      > need to be capitalized, or upper cased. I would like to use ^!Replace
      > statements to change them.
      > As an example text:
      > Title: a dog's tale
      > I would like to replace as follows:
      > ^!Replace "^(Title: )(.+)\R >> "$1uppercase$2\n" ARTSW
      > The result would be
      > Title: A DOG'S TALE
      > I have been able to do it with a ahort subroutine, using the Toolbar
      > Uppercase command, but that adds a lot of time to the processing of
      > large files.
      > Can anyone help?
      > Does anyone that reads this forum know if the \L, \l, \U, \u commands
      > are going to be added any time soon? (Which would make the above
      > function easy...
      NoteTab uses a 3rd Party Delphi component in its regex processing; the
      Delphi component provides the replacement tokens. In February this year,
      I corresponded with the component's author and suggested some
      enhancements, including case modifiers. His disappointing response was
      that he preferred not to implement non-standard regex replacements.

      You can make a NoteTab clip that uses ^!Find instead of ^!Replace
      commands, loops through the document, and uses the ^$StrUpper$ function
      to transform the highlighted text. For example

      ^!Find "(?<=Title: ).+" RS

      should highlight the right thing.

      ^!InsertText ^$StrUpper(^$GetSelection$)$

      should transform it to upper case.

      If you would care to install PowerPro I could help you can do that with
      a fast regex.pcrereplace function that includes case modifiers, e.g.,
      $U2. It also supports a count index token $#. Its other replacement
      tokens are pretty much identical to NoteTab's. PowerPro is not an
      editor. It has Windows scripting capability. There is a ready made GUI
      script available for it that allows you to display a file, process regex
      replacements, and save the result.

      The main program is here: http://powerpro.webeddie.com/

    • Show all 10 messages in this topic