Exporting list of text between delimeters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nassausky
    New Member
    • Mar 2007
    • 5

    Exporting list of text between delimeters

    Hiya all,

    New to this forum.. It looks like perl can do a real nice job of extracting text and more. How can i extract a bunch of text in a large 77 page text file "document1. txt" where it contains text between brackets..

    For example:

    This is a test document of [widget1] and [object2]. It contains many,
    many lines of text and [words3].

    Where the output file would be:

    widget1
    object2
    words3

    After i get the hang of it, i'll see if i can do the fine adjustments myself.
    Thanks :)

    Mike
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Code:
    perl -ne "s/\[([^\]]+)\]/print $1.\"\n\"/eg" document1.txt > output.txt
    You might have to change the outside double-quotes to single-quotes on your system.

    Comment

    Working...