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

22570RE: [NTB] Remove x number of characters from a line of text

Expand Messages
  • John Shotsky
    May 27 10:08 PM
    • 0 Attachment
      Sure. First, the answer about how to make it repeatable is to create a clip library of your own, and add these functions
      to it. An easy way to do that is to take one of the provided sample clip libraries, copy it and name it what you want.
      Then, draw a line at the top, (add a clip name of dashes only ), and start adding your own clips above the line,
      reserving the older ones as examples as you learn new things you want to accomplish. The Sample Code and Utilities are
      good ones to start with � after a while, you'd just delete all the stuff below your line as you add more clips to your
      custom library. My custom clip library has about 32,000 lines, probably half of those comments. I wrote a clip that
      strips all comments out, just so I can see the base library size without comments. These are the sorts of things you can
      learn to do.

      So, for my clip example, assuming you want ONLY 2 or 3 digits removed, it goes as follows:
      The \x20 is a code for a space. I use those most of the time because you can SEE them. You can use actual spaces, but
      that can lead to confusion.
      The \d means a digit � a number.
      The second \d means another digit, meaning it must have at least two. As Alec indicated, there is more than one way to
      code this, but they work the same.
      The third \d with a question mark means grab it if it's there, but if not, that's ok, go with what you have. It means
      zero or 1 digit.
      The $ means that it has to occur at the end of the line.
      So, a space, followed by two or three digits, at the end of a line meets the requirement.
      If ANY number of digits were to be removed, you would use \d+ in place of \d\d\d?, which means any number of digits.

      To write this into a clip, you would create a new clip and add this into it, then save it:
      ^!Replace "\x20\d\d\d?$" >> "" ARSW
      It will do exactly what the replace above does, but it is kept permanently, so you can use it any time you need it
      without retyping the replace dialog.

      RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

      From: notetab@yahoogroups.com [mailto:notetab@yahoogroups.com] On Behalf Of biwilliams
      Sent: Sunday, May 27, 2012 20:07
      To: notetab@yahoogroups.com
      Subject: Re: [NTB] Remove x number of characters from a line of text

      That's awesome!! Thanks heaps!
      If I can be a pita, can you explain what each character in that regex string means? Or better yet, point me to somewhere
      where I can learn the syntax?

      In answer to your questions, in the current batch of text files I need to manipulate, no, the string of numerals at the
      end of each line is ALWAYS either 2 or 3 characters in length. But that doesn't mean that at some point down the track I
      won't need to strip out 4 or more, or maybe only 1 character.
      Also, I'm intrigued by your question about reusing the query for multiple jobs. Is that easy to set up?

      Thanks again for the speedy (and functional) response! :)

      --- In notetab@yahoogroups.com <mailto:notetab%40yahoogroups.com> , "John Shotsky" <jshotsky@...> wrote:
      > Yes, that's easy, but first some questions:
      > Can there be ONE number after a space at the end of a line that you want to keep?
      > Can there be FOUR or more numbers after that space at the end of a line that you want to keep?
      > If it is as simple as removing any numbers at the end of a line that are preceded by a space? That is very easy. If it
      > is ONLY two or three numbers, that is slightly different.
      > Do you want a clip that you can repeatedly use for this job, or do you just want to use a find/replace to do it one
      > time?
      > If the latter, in the find box, you choose the regex option, and enter \x20\d+$ and replace it with nothing for any
      > numbers after a space at the end of a line.
      > For the case where it is ONLY two or three numbers, it would be \x20\d\d\d?$ and replace that with nothing.
      > Regards,
      > John
      > RecipeTools Web Site: <http://recipetools.gotdns.com/> http://recipetools.gotdns.com/

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