in reply to weird regex question

If you use !$!, only $! get interpolated, not the entire expression. In your case, $!, in string context, will be the empty string. So, you end up with
/^.{!}(.{5})/
which is not going to match. If you want to interpolate the expression, use:
/^.{@{[!$!]}}(.{5})/

Replies are listed 'Best First'.
Re^2: weird regex question
by Anonymous Monk on Apr 25, 2012 at 17:07 UTC
    hmm kinda makes sense, so how would i do the 5?
      What do you mean, how would I do the 5?
        ohh nevermind i figured it out.. thanks :D
      1 and 5
      my $string = "hello world"; print $string =~ /^.{@{[!$[]}}(.{${\($]<<$]>>$])}})/; # 'ello '
      or print $]>>$?;