in reply to Re: Regex with lookahead
in thread Regex with lookahead
Yep, Data::Dumper also works, it's just not as "cool".
Here's an alternate that only allows Flatten, in, or out (but note that multiples are allowed)
#!/usr/bin/perl # http://perlmonks.org/?node_id=1196747 use strict; use warnings; use Data::Dumper; while(<DATA>) { /RepeatingGroup\s*=\s* (?<GroupID>\b\w+\b) (\s*,\s* ((?<Flatten>\bFlatten\b)|(?<Direction>\b(in|out)\b)) )* \s*$/x or next; print $_, Dumper \%+; } __DATA__ RepeatingGroup = Waiver, Flatten, out RepeatingGroup = Waiver, out RepeatingGroup = Waiver, out, Flatten RepeatingGroup = Waiver , in RepeatingGroup = Waiver , Flatten RepeatingGroup = LEI, out, Flatten
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Regex with lookahead
by stevieb (Canon) on Aug 05, 2017 at 01:29 UTC | |
by Your Mother (Archbishop) on Aug 05, 2017 at 17:50 UTC | |
by stevieb (Canon) on Aug 05, 2017 at 20:20 UTC |