我正在尝试收集验证 SVG 基本数据类型所需的所有 perl 正则表达式。到目前为止,我有:
my $w = "\\s*";
my $hexdigit = "[0-9A-Fa-f]";
my $c = "$w,$w";
my $i = "[0-9]+";
my $integer = "[+-]?$i";
my $p = "${i}%";
my $number = "(?:$integer|[+-]?[0-9]*\.[0-9]+(?:[Ee]$integer)?)";
my $angle = "(?:$number$w(?:deg|grad|rad)?)";
my $color = "(?:#$hexdigit$hexdigit$hexdigit(?:$hexdigit$hexdigit$hexdigit)?|".
"rgb\\($w$i$c$i$c$i$w\\)|".
"rgb\\($w$p$c$p$c$p$w\\)|".
'(?:'.join("|", sort keys %{svgColours()}). '))';
my $length = "(?:$number(?:em|ex|px|in|cm|mm|pt|pc)?)";
my $coordinate = $length;
my $frequency = "$number(?:Hz|kHz)";
my $FuncIRI = "url\(.+\)";
my $numberOptionalNumber = "(?:$number|$number$c$number)";
my $paint = "(?:fill|stroke)";
my $time = "(?:$number(?:ms|s))";
如果您看到改进的机会,请告诉我。