in reply to Re^2: Regex to grab data after the work "branch from"
in thread Regex to grab data after the work "branch from"

.../file.cpp#1,#8 ^ ...\/(.*))\#\,(\#\d+)$/ ^

You don't have anything in your regex that would match the 1.

Replies are listed 'Best First'.
Re^4: Regex to grab data after the work "branch from"
by perl_mystery (Beadle) on Dec 14, 2010 at 09:36 UTC

    Thanks for pointing that out,now when I try to print it,I see a "1" getting printed,looks like its printing the number of times it matched,where am I going wrong?

    /branch\sfrom(.*\/(.*))\#\d+\,(\#\d+)$/xmsg;
      looks like its printing the number of times it matched

      In scalar context, the return value of the match indicates whether it matched.

      Fixing that, plus a number of other things, should leave you with something like

      my $update_p4filelog = "...xyz branch from //source/qcom/qct/multimedi +a/qtv/player/audioplayer/rel/1.1/src/file.cpp#1,#8"; my ($path, $ver) = $update_p4filelog =~ /branch from (.*\/.*)#\d+,(#\d ++)$/; my $update_base_branched_p4path = "$path$ver"; print "$update_base_branched_p4path\n";

        I actually want to make the "#\d+," part optional in the regex,so I changed it to [#\d+,]?,it served part of my purpose,it became optional but I want to stop it from printing.how do i do that?

        ($path, $ver) = $update_p4filelog =~ /branch from (.*\/.*)[#\d+,]?(#\d ++)$/;