Archimede wrote:
> I have a little question: is it possible to use a
repatition quantifier
> like "" but instead of "n" using
a reference to a named group? Ex.
> {k<name>}
>
> For example i need to detect a pattern like this:
> "3;string;string;string;" or
"2;string;string;"
>
> I had tryed using this patern
"(d+);([^;]+;)" or a named
> equivalent version
"(?<howmany>d+);([^;]+;){k<howmany>}"
; but without
> success. I think than "" can accept only a
number as "n".
>
> Is there a workaround for doing this?
In Perl, this can be done by using an embedded code
construct
(??), like:
(d+)(??{ "(;[^;]+){$1}" })
Or we can use some more regexes to do it, like using 'c',
'g' modifiers
and the 'G' anchor, i.e.:
while ( $str =~ /(d+)/g ) {
my $num = $1;
$str =~ /G((?:;[^;]*){$num})/gc and print
"$num$1";
}
Dont know how other tools handle this though.
Xicheng
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regex googlegroups.com
To unsubscribe from this group, send email to
regex-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps-beta.google.com/group/regex
-~----------~----~----~----~------~----~------~--~---
|