in reply to Re^2: Problem in pattern matching with alternation
in thread Problem in pattern matching with alternation
I'll propose the following, which is based on code and data in the original post at the top of this thread. Please try this out, tell us whether it works for you, and if it doesn't (and you are still stumped about how to make it work), tell us exactly how it should work.
The difference between that and the OP code is:#!/usr/bin/perl use strict; use warnings; while (<DATA>) { print "$1\n" if ( m{^\*\s+(?:/\w+)+\s+(.+?)\s+} ); } __DATA__ * /vobs/bt_rel /usr/add-on/puccase_vob01/ccvob01/bt_rel.vbs public (re +plicated) * /scm /usr/add-on/puccase_vob01/ccvob01/scm.vbs public (replicated) * /v_dialermidtier /usr/addon/puccase_vob01/ccvob01/v_dialermidtier.vb +s public (replicated) * /v_dialer /usr/add-on/puccase_vob01/ccvob01/v_dialer.vbs public (rep +licated) * /vobs/UMTools /user/addon/puccase_vob01/ccvob01/UMtools.vbs replicat +ed)
If you are just trying to get the third space-delimited token from each line of input, you could do this for each line, instead of the regex match:
(updated to include "+" outside the parens -- thanks, naikonta!)print +(split /\s+/)[2]; # print third "word" of line
If the data shown above is not correct, show us the actual data (inside <code> tags, please). If the output is not what you want, show us exactly what you want (based on the correct input data, again using <code> tags).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Problem in pattern matching with alternation
by naikonta (Curate) on Aug 13, 2007 at 08:52 UTC | |
|
Re^4: Problem in pattern matching with alternation
by perladdict (Chaplain) on Aug 12, 2007 at 17:35 UTC | |
by graff (Chancellor) on Aug 12, 2007 at 20:13 UTC | |
by FunkyMonk (Bishop) on Aug 12, 2007 at 17:57 UTC |