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

304Re: [NTS] Re: Regular Expression to Strip lines of "]"

Expand Messages
  • Alan C
    May 25, 2005
    • 0 Attachment
      perl -pe 's/\]+\n//g' < file.ddf > file.txt

      That did it here on Linux. Sometimes Win needs double quotes if trying
      it on Windows.

      http://www.perl.com/pub/a/2004/08/09/commandline.html?page=2

      scroll down near bottom, entitled "In-place editing"

      tr can do lots. I never know when to use substitution operator (regex)
      versus tr transliteration operator.

      Alan.

      lm_hamilton wrote:

      >After much Googling and further trial and error, I found it.
      >
      >I thought I had tried this before and it did not work, but I was mistaken.
      >
      >Here it is:
      >
      >tr/\x5D+\n//d;
      >
      >The transliteration operator tr also can use y.
      >
      >Larry
      >
      >--- In ntb-scripts@yahoogroups.com, "lm_hamilton" <lmh@h...> wrote:
      >
      >
      >>I have a file that has hundreds of lines of several hundred right
      >>square brackets "]".
      >>
      >>I cannot control how I receive this file, but I have to clean it up. I
      >>can get it so that there is the junk at the end, and then have to
      >>manually delete it.
      >>
      >>I have tried these perl one liners to no avail, it just spits out a
      >>copy of the file.
      >>
      >>perl -p -e 's/\x5D+//g' file.ddf > file.txt
      >>perl -p -e 's/\]+//g' file.ddf > file.txt
      >>perl -p -e 's/\\]+//g' file.ddf > file.txt
      >>perl -p -e 's/]+//g' file.ddf > file.txt
      >>perl -p -e 's/]+\n//g' file.ddf > file.txt
      >>perl -p -e 's/]*\n//g' file.ddf > file.txt
      >>perl -p -e 's/\x5D*\n//g' file.ddf > file.txt
      >>perl -pe 's/]*\n//g' file.ddf > file.txt
      >>perl -pe 's/\x5D*\n//g' file.ddf > file.txt
      >>perl -pe 's/[\x5D*\n]//g' file.ddf > file.txt
      >>
      >>What I want to do is just strip out the entire line of "]" and the
      >>line break.
      >>
      >>It is a piece of cake in NoteTab, but I need to do it in Perl.
      >>
      >>Any ideas or pointers on what I am missing are greatly appreciated!
      >>
      >>THANKS!
      >>
      >>Larry Hamilton
      >>
      >>
      >
      >
      >
      >
      >
      >ntb-scripts-unsubscribe@yahoogroups.com
      >
      >
      >Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
    • Show all 4 messages in this topic