in reply to capturing multiple repeated regex subparts
Regexps are useful for validation, extraction and tokenizing. However, they are not as strong at parsing, as you have discovered. Parsing is nontheless possible, using advanced features.
use v5.8.0; # or higher # For $^N our @rv; our @temp_rv; / (text); (?{ local @temp_rv = ( @temp_rv, $^N ) }) (?: (float) (?{ local @temp_rv = ( @temp_rv, $^N ) }) (?:non-num) ){4} (?{ @rv = @temp_rv }) /x;
Tested.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: capturing multiple repeated regex subparts
by japhy (Canon) on Feb 17, 2006 at 21:18 UTC |