NOTEI think it's actually look-behind assertion he needs.

($var =~/(?<=use )neighbor[[:alpha:]-]* ([[:alnum:]\.-:]+)/) and do{ print $1; };
output 2001:504:0:4::6181:1 If that is the output the OP wanted.

Because with "negative look-behind assertion", the match is not successful (failed). In fact, there is no output.
Checked with use re 'debug';
.. produces ..
Compiling REx `(?<!use )neighbor[[:alpha:]-]* ([[:alnum:]\.-:]+)' size 42 Got 340 bytes for offset annotations. first at 1 1: UNLESSM[-4](7) 3: EXACT <use >(5) 5: SUCCEED(0) 6: TAIL(7) 7: EXACT <neighbor>(10) 10: STAR(23) 11: ANYOF[\-A-Za-z+utf8::IsAlpha](0) 23: EXACT < >(25) 25: OPEN1(27) 27: PLUS(40) 28: ANYOF[.-:A-Za-z+utf8::IsAlnum](0) 40: CLOSE1(42) 42: END(0) anchored `neighbor' at 0 floating ` ' at 8..2147483647 (checking ancho +red) minlen 10 Offsets: [42] 8[4] 0[0] 5[4] 0[0] 8[0] 8[0] 10[8] 0[0] 0[0] 30[12] 18[12] 0[0] 0 +[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 31[1] 0[0] 32[1] 0[0 +] 48[15] 33[15] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0] 0[0 +] 49[1] 0[0] 50[0] Guessing start of match, REx `(?<!use )neighbor[[:alpha:]-]* ([[:alnum +:]\.-:]+)' against `use neighbor 2001:504:0:4::6181:1'... Found anchored substr `neighbor' at offset 4... Found floating substr ` ' at offset 12... Starting position does not contradict /^/m... Guessed: match at offset 4 Matching REx `(?<!use )neighbor[[:alpha:]-]* ([[:alnum:]\.-:]+)' again +st `neighbor 2001:504:0:4::6181:1' Setting an EVAL scope, savestack=5 4 <use > <neighbor> | 1: UNLESSM[-4] 0 <> <use neighbor> | 3: EXACT <use > 4 <use > <neighbor> | 5: SUCCEED could match... failed... Match failed Freeing REx: `"(?<!use )neighbor[[:alpha:]-]* ([[:alnum:]\\.-:]+)"'


UPDATE:
NOTE: I think I got this wrong, and kennethk was right! Since, the OP gave a condition on which the regex should match as "when the string doesn't have USE" and the sample he gave has it.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

In reply to Re^2: Quick Regex trouble by 2teez
in thread Quick Regex trouble by jrvd

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.