in reply to Extracting part of a substring with one regex (with backreference?)

Hi loris, try this.

my $xpath = 'BoringNode[1]/InterestingNode[@InterestingAttribute="outg +rabe"]/AnotherBoringNode[@BoringAttribute="grey"]'; print $xpath =~ /InterestingNode\[[^"]+\"([^"]+)\"\]/;

Regards,
Velusamy R.

  • Comment on Re: Extracting part of a substring with one regex (with backreference?)
  • Download Code

Replies are listed 'Best First'.
Re^2: Extracting part of a substring with one regex (with backreference?)
by loris (Hermit) on Oct 28, 2005 at 09:20 UTC

    Thanks Samy_rio, but when I do

    print "$1\n";
    I get

    outg +rabe

    on my box.

    ?

    loris


    "It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."
      Um, that's because you copied and paste the code as it appeared in your browser, and perlmonks.org defaults to wrapping code at 60 chars or so. Try the "d/l" (download code) link next time.

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

        See this node.

        Thanks,

        loris


        "It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."
      I think that you have cut-and-pasted Samy_rio's code directly from the node, so you also copied the plus sign and embedded newline that the Perlmonks site added for code wrapping. Click the 'download' link, and you will see that his code is two lines, not three.

        Uh oh, more egg on face. Sorry.

        loris


        "It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ."