K
Klaus
Hello everybody,
I am trying to do a simple task: creating a regular expression with
qr{...}xms containing a simple character class. Then I can obviously
create the negated character class by putting a caret symbol at the
beginning inside the [...].
So far so good.
However, when I try (naively) to calculate the negated class from the
original character class, I get a compile time error:
Invalid [] range "x-i" in regex;
marked by <-- HERE in m/[^(?msx-i <-- HERE :[abc123])]/
at C:\test_regexp.pl line 6.
Here is my program
=========
use 5.012;
use warnings;
my $regexp_positive = qr{[abc123]}xms;
my $regexp_negated = qr{[^abc123]}xms;
my $calculated_negated = qr{[^$regexp_positive]}xms;
say "regexp_positive = $regexp_positive";
say "regexp_negated = $regexp_negated";
say "calculated_negated = $calculated_negated";
========
I understand that putting "(?msx-i" into a character class is not the
way forward, but how do I calculate the negated character class ?
Thanks in advance for your response.
-- Klaus
I am trying to do a simple task: creating a regular expression with
qr{...}xms containing a simple character class. Then I can obviously
create the negated character class by putting a caret symbol at the
beginning inside the [...].
So far so good.
However, when I try (naively) to calculate the negated class from the
original character class, I get a compile time error:
Invalid [] range "x-i" in regex;
marked by <-- HERE in m/[^(?msx-i <-- HERE :[abc123])]/
at C:\test_regexp.pl line 6.
Here is my program
=========
use 5.012;
use warnings;
my $regexp_positive = qr{[abc123]}xms;
my $regexp_negated = qr{[^abc123]}xms;
my $calculated_negated = qr{[^$regexp_positive]}xms;
say "regexp_positive = $regexp_positive";
say "regexp_negated = $regexp_negated";
say "calculated_negated = $calculated_negated";
========
I understand that putting "(?msx-i" into a character class is not the
way forward, but how do I calculate the negated character class ?
Thanks in advance for your response.
-- Klaus