Hi Schlomi, thank you so much for such a quick response.
On Thu, 2011-08-25 at 11:56 +0300, Shlomi Fish wrote: > ׁHi Honza, > > On Thu, 25 Aug 2011 10:42:20 +0200 > Honza Mach <jan.m...@cesnet.cz> wrote: > > > Hi everybody, > > > > I was wondering, if it is possible to use backreferences in the pattern > > repetition bracket operator. > > > > Consider the following string: > > > > my $string = "5 abcdefghijklmn"; > > > > The number five at the beginning of the string means, that I want to > > extract first five characters from the latter part of the string. I > > tried the following code, but it doesn`t work: > > > > $string =~ s/(\d+)\s+(.{\g1})//; > > print "extracted: $1 $2\n"; > > > > The desired output would be: > > > > extracted: 5 abcde > > > > It seems, that it is not possible to use backreferences within the > > bracket operator (or am I doing something wrong?). > > > > I don't think it's possible, because the perl regex engine is not that smart. That`s a pity, but I will walk around it somehow. > > Is there other solution to my problem. > > > > You can use incremental parsing using \G and /g. See: > > http://perl-begin.org/uses/text-parsing/ Thank you for the tip, I will check it out. > Regards, > > Shlomi Fish > Regards Honza Mach > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > Freecell Solver - http://fc-solve.berlios.de/ > > Knuth is not God! Typing “God” into Google and pressing “I’m Feeling Lucky” > will not lead you to his homepage. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . >
smime.p7s
Description: S/MIME cryptographic signature