File: regex.pl

package info (click to toggle)
libgraphviz-perl 2.24-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 952 kB
  • sloc: perl: 2,174; makefile: 8
file content (22 lines) | stat: -rwxr-xr-x 612 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl -w
#
# An example of visualising a regular expression using GraphViz::Regex

use strict;
use lib '../lib';
use GraphViz::Regex;

#my $regex = '((a{0,5}){0,5}){0,5}[c]';
#my $regex = '([ab]c)+';
#my $regex = '^([abcd0-9]+|foo)';
#my $regex = '(?-imsx:(?ms:((?<=foo)|(?=ae|io|u))?(?(1)bar|\x20{4,6})))';
#my $regex = '[\d]';
#my $regex = '()ef';
#my $regex = 'a(?:b|c|d){6,7}(.)';
#my $regex = '(x)?(?(1)b|a)'; # error!
my $regex = '^([0-9a-fA-F]+)(?:x([0-9a-fA-F]+)?)(?:x([0-9a-fA-F]+))?'; # pretty

my $graph = GraphViz::Regex->new($regex);

#warn $graph->_as_debug;
$graph->as_png("regex.png");