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

303Re: Regular Expression to Strip lines of "]"

Expand Messages
  • lm_hamilton
    May 25 9:38 AM
    • 0 Attachment
      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
    • Show all 4 messages in this topic