I use this script for practicing regex:
#!/usr/bin/env perl use strict; use warnings; use 5.014; my $string; my $pattern; while ( ( say "Input template string:" ) && ( $string = <> ) ) { while ( ( say "Input pattern:" ) && ( $pattern = <STDIN> ) ) { chomp $pattern; my $regex = qr/$pattern/p; $string =~ $regex; say "${^PREMATCH} \x{25a0}\x{25a0}${^MATCH}\x{25a0}\x{25a0} ${ +^POSTMATCH}"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex practice script
by jwkrahn (Abbot) on Jul 25, 2011 at 08:23 UTC | |
by JavaFan (Canon) on Jul 25, 2011 at 14:15 UTC | |
by kindlychung (Initiate) on Jul 25, 2011 at 15:35 UTC |