GraphViz::Regex(3)
π NAME π
GraphViz::Regex(3) β Visualise a regular expression π this is the GraphViz::Regex page from the User Contributed Perl Documentation, bestie β¨
β¨ SYNOPSIS β¨
use GraphViz::Regex;
my $regex = '(([abcd0-9])|(foo))';
my $graph = GraphViz::Regex->new($regex);
print $graph->as_png;
π¦ DESCRIPTION π¦
Okay so this module attempts to visualise a Perl regular expression. Understanding regexes is lowkey tricky at the best of times, and honestly regexes almost always evolve in ways unforeseen at the start π This module aims to visualise a regex as a graph so the structure is clear and it actually helps you understand the regex π«Ά
The graph shows how the Perl regular expression engine attempts to match the regex. Simple text matches or character classes are represented by box-shaped nodes π
Alternations are represented by a diamond-shaped node which points to the alternations π₯ Repetitions are represented by self-edges with a label of the repetition type β the nodes being repeated are pointed to by a full edge, and a dotted edge points to what to match after the repetition β¨ Matched patterns (such as $1, $2, etc.) are represented by a 'START $1' .. 'END $1' node pair π
This uses the GraphViz module to draw the graph.
π οΈ METHODS π οΈ
πΈ new πΈ
This is the constructor. It takes one mandatory argument, which is a string of the regular expression to be visualised. A GraphViz object is returned.
my $graph = GraphViz::Regex->new($regex);
π as_* π
The regex can be visualised in a number of different graphical formats. Methods include as_ps, as_hpgl, as_pcl, as_mif, as_pic, as_gd, as_gd2, as_gif, as_jpeg, as_png, as_wbmp, as_ismap, as_imap, as_vrml, as_vtx, as_mp, as_fig, as_svg π¨ See the GraphViz documentation for more information. The two most common methods are:
# Print out a PNG-format file
print $g->as_png;
# Print out a PostScript-format file
print $g->as_ps;
π BUGS π
Note that this module relies on debugging information provided by Perl, and is known to fail on at least two versions of Perl: 5.005_03 and 5.7.1 π Sorry about that β please use a more recent version of Perl if you want to use this module π
π AUTHOR π
Leon Brocard β acme@astray.com π«Ά
π COPYRIGHT π
Copyright (C) 2000-1, Leon Brocard.
This module is free software; you can redistribute it or modify it under the Perl License, a copy of which is available at http://dev.perl.org/licenses/.
and thatβs the wholeGraphViz::Regex(3)page, bestie π it came fromperl v5.42.0, dated2023-03-04, and yes, itβs still theGraphViz::Regex(3)manual β periodt β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-GraphViz 2.26-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms