There is an experimental feature (that I haven't used yet), Extended Bracketed Character Classes, that should allow you to define your own classes (or more specifically, compose a character class out of others, which you can also interpolate into a regex).

However, /\b(?:[[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}\b/ is not a character class (emphasis mine):

A character class is a way of denoting a set of characters in such a way that one character of the set is matched. It's important to remember that: matching a character class consumes exactly one character in the source string.

What you've got is a whole regex, and I think that LanX is right that simply compiling that into a variable with qr and interpolating that into another regex is the best way to go. Later in that thread you asked if you could isolate the variable, and the usual ${} can be applied here too, as well as the /x modifier:

my $x = qr/foo/; my $y = qr/${x}bar/; # (?^:(?^:foo)bar) my $z = qr/ $x bar /x; # (?^x: (?^:foo) bar )

Regarding the example you've shown, note there is $RE{net}{IPv4} from Regexp::Common::net.

Minor edits for clarification.


In reply to Re: Defining your own regex character class by haukex
in thread Defining your own regex character class by igoryonya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.