Corion and shmem have both suggested an approach using a split on whitespace. You would need to take precautions if the path can include spaces. This can be done by isolating the path field using three-argument splits from either end of the record.

use strict; use warnings; my @records = ( qq{FRAG 1 1 2000000 0 0 0 0 \\\\172.20.13.49\\backup\\rbgmst02_dd2\ +\stu1\\CPOSTA_1221170039_C1_F1 rbgmst02 65536 0 0 -1 0 *NULL* 1222379 +639 1 65537 0 0 0 0 0 0 0}, qq{FRAG 1 1 2000000 0 0 0 0 \\\\172.20.13.49\\backup\\rbgmst02_dd2\ +\New Folder\\Space File rbgmst02 65536 0 0 -1 0 *NULL* 1222379639 1 6 +5537 0 0 0 0 0 0 0}, ); foreach my $record ( @records ) { my @leftFields = split m{\s+}, $record, 9; my $path = ( reverse map { $_ = reverse } split m{\s+}, reverse( $leftFields[ 8 ] ), 18 )[ 0 ]; my $basename = ( split m{\\}, $path )[ -1 ]; print qq{$path\n $basename\n}; }

The output,

\\172.20.13.49\backup\rbgmst02_dd2\stu1\CPOSTA_1221170039_C1_F1 CPOSTA_1221170039_C1_F1 \\172.20.13.49\backup\rbgmst02_dd2\New Folder\Space File Space File

I hope this is of interest.

Cheers,

JohnGG


In reply to Re: Regular expression by johngg
in thread Regular expression by PugSA

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.