loris has asked for the wisdom of the Perl Monks concerning the following question:
Hello all,
I wanted to remove the final section of an XPath string using a regex. I obviously don't understand non-greediness, because I though this would work:
my $xpath = 'BoringNode[1]/InterestingNode[@InterestingAttribute="outg +rabe"]/AnotherBoringNode[5]'; $xpath =~ s|\/(.*?)$||; print $xpath . "\n";
I had hoped to get
BoringNode[1]/InterestingNode[@InterestingAttribute="outgrabe"]
Can anyone help?
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex: Matching last of repeated character to end of string
by jbware (Chaplain) on Nov 04, 2005 at 12:30 UTC | |
|
Re: Regex: Matching last of repeated character to end of string
by davis (Vicar) on Nov 04, 2005 at 12:32 UTC | |
|
Re: Regex: Matching last of repeated character to end of string
by Perl Mouse (Chaplain) on Nov 04, 2005 at 12:53 UTC | |
by ambrus (Abbot) on Nov 04, 2005 at 22:17 UTC | |
|
Re: Regex: Matching last of repeated character to end of string
by Aristotle (Chancellor) on Nov 04, 2005 at 13:52 UTC | |
|
Re: Regex: Matching last of repeated character to end of string
by radiantmatrix (Parson) on Nov 04, 2005 at 14:57 UTC | |
by japhy (Canon) on Nov 04, 2005 at 15:04 UTC |