in reply to Regex to grab data after the work "branch from"

/branch from(.*/(.*))\#\,(\#\d+)$/; ^

Either escape the slash, or use a different delimiter, e.g. m|...|

(Also, '#' isn't a regex metacharacter (unless you use /x), so no need to escape it here.)

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

    The error is gone but I dont see any data getting printed

    p4filelog data below,$update_p4filelog has below data

    //depot/asic/msmshared/users/QTVOEMDrops/qtv/player/audioplayer/file.cpp

    ... #2 change 1548905 edit on 2010/12/09 by sri@SRIXP (ktext) 'Audio loss when doing nultiple '

    ... #1 change 1548876 branch on 2010/12/09 by sri@SRIXP (ktext) 'Branching for orphan release fo'

    ... ... branch from //source/qcom/qct/multimedia/qtv/player/audioplayer/rel/1.1/src/file.cpp#1,#8

    $update_p4filelog=`p4 filelog $1`; print "$update_p4filelog\n";# $update_base_branched_p4path = $update_p4filelog =~ /branch from(.*\/( +.*))\#\,(\#\d+)$/xmsg; print "$update_base_branched_p4path\n";# doesnt print anything,expecti +ng //source/qcom/qct/multimedia/qtv/player/audioplayer/rel/1.1/src/file.c +pp#8 to be printed
      Maybe you should try to fix up the regex? use re 'debug';
        I created a sample script and used re 'debug',I really couldn't understand the output ...
        #!/usr/bin/perl use strict; use warnings; use Data::Dumper; use re 'debug'; my $file= "//depot/asic/msmshared/users/QTVOEMDrops/7600/3555473R/qtv/ +player/audioplayer/audiocmx.cpp"; my $update_p4where=`p4 where $file`; #print "$update_p4where"; my $update_p4filelog=`p4 filelog $file`; print "$update_p4filelog\n"; my $update_base_branched_p4path = $update_p4filelog =~ /branch\sfrom(. +*\/(.*))\#\,(\#\d+)$/xmsg; print "$update_base_branched_p4path\n";

        Compiling REx `branch from(.*/(.*))\#,(\#\d+)$' size 30 first at 1

        1: EXACT <branchfrom>(5) 5: OPEN1(7) 7: STAR(9) 8: SANY(0) 9: EXACT </>(11) 11: OPEN2(13) 13: STAR(15) 14: SANY(0) 15: CLOSE2(17) 17: CLOSE1(19) 19: EXACT <#,>(21) 21: OPEN3(23) 23: EXACT <#>(25) 25: PLUS(27) 26: DIGIT(0) 27: CLOSE3(29) 29: MEOL(30) 30: END(0)

        anchored `branch' at 0 floating `#,#' at 12..2147483647 (checking anchored) minlen 16

        //depot/asic/msmshared/users/QTVOEMDrops/7600/3555473R/qtv/player/audioplayer/audiocmx.cpp ... #2 change 1548905 edit on 2010/12/09 by c_krisri@C_KRISRIXP (ktext) 'Audio loss when doing nultiple ' ... #1 change 1548876 branch on 2010/12/09 by c_krisri@C_KRISRIXP (ktext) 'Branching for orphan release fo' ... ... branch from //source/qcom/qct/multimedia/qtv/player/audioplayer/rel/1.1/src/audiocmx.cpp#1,#8

        Guessing start of match, REx `branch\sfrom(.*/(.*))\#,(\#\d+)$' against `//depot/asic/msmshared/users/QTVOEMDrops/7600/3555473R/qtv/p...'...

        Found anchored substr `branch' at offset 219... Contradicts floating substr `#,#', giving up...//Why is it giving up?why isn't it goint to the next line??

        Match rejected by optimizer Freeing REx: `branch\sfrom(.*/(.*))\#,(\#\d+)$'

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

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

        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;