Here's a little script that might illustrate some of concepts presented by the other monks:

use strict; my @data = <DATA>; print "1:\n"; #1: print lines that contain something like '[[106535 abc]]' foreach my $line (@data) { print $line if $line =~ /\[\[\d+ \w+\]\]/; } print '-' x 20, "\n2:\n"; #2: print lines that start with something like '[[106535 abc]]', but #with an indeterminate number of brackets foreach my $line (@data) { print $line if $line =~ /^\[+\d+ \w+\]+/; } print '-' x 20, "\n3:\n"; #3: print lines that start with something like '[[106535 abc]]' foreach my $line (@data) { print $line if $line =~ /^\[\[\d+ \w+\]\]/; } print '-' x 20, "\n4:\n"; #4: print lines that start with two brackets, six digits, #a space, three alphanumerics and two brackes foreach my $line (@data) { print $line if $line =~ /^\[\[\d{6} \w{3}\]\]/; } print '-' x 20, "\n5:\n"; #5: print out the value inside of the brackets and then #the rest of the line foreach my $line (@data) { print "$1 - $2\n" if $line =~ /^\[\[(\d+ \w+)\]\]\s(.+)/; } __DATA__ [[106535 abc]] blah blah blah... [[298727 xyz etc etc etc etc etc [[093 hij]] so on and so on and so on [[459313 def] more more more more 459313 yadda yadda yadda yadda yadda [[349581 wxy]] yack yack yack yack yack they're coming to [[549412 qqq]] me away ipsum plurum ipsum plurum ipsum plurum ... ... ... ...
Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"

In reply to Re: regular expressions help by Art_XIV
in thread regular expressions help by da97mld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.