<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div class="h5">âÏÌÅÅ ÉÎÔÅÒÅÓÎÙÊ ÐÒÉÍÅÒ: IP-ÁÄÒÅÓÁ, Perl5</div></div>
ÆÁÊÌ IPType.pm<br>
<br>
package IPType;<br>
use Regexp::Common 2.105;<br>
use MooseX::Types::Moose qw( Str );<br>
use MooseX::Types -declare => [ qw(IP) ];<br>
<br>
subtype IP, as Str, where {<br>
 š š š š$_ =~ /\A $RE{net}{IPv4} \z/msx<br>
}, message {<br>
 š š š š"'$_' is not a valid IP";<br>
};<br>
<br>
ÆÁÊÌ <a href="http://typed.pl" target="_blank">typed.pl</a><br>
<br>
 š šuse IPType qw/IP/;<br>
 š šuse MooseX::Lexical::Types qw/IP/;<br>
<br>
 š šmy IP $foo; š # declare typed variable<br>
 š š$foo = '192.168.1.1'; š š # works<br>
 š š$foo = 'bar'; š# fails</blockquote><div><br></div><div><br></div><span class="Apple-style-span" style="font-family: Verdana; font-size: 12px; color: rgb(35, 35, 35); "><pre style="margin-top: 15px; margin-right: 15px; margin-bottom: 15px; margin-left: 15px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(243, 243, 243); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); overflow-x: auto; overflow-y: auto; width: 490px; font-size: 12px; background-position: initial initial; background-repeat: initial initial; ">
import java.util.regex.*;

public class TestRegexp {
    public static final Pattern pattern = Pattern.compile
            ("[a-zA-Z]{1}[a-zA-Z\d\u002E\u005F]+@([a-zA-Z]+\u002E){1,2}((net)|(com)|(org))");

    public static void doMatch(String word) {
        String output = "Validation for " + word;
        Matcher matcher = pattern.matcher(word);
        if (matcher.matches())
            output += " passed."
        else
            output += " not passed."
        System.out.println(output);
    }

    public static void main(String[] args) {
        doMatch("<a href="mailto:c0nst@money.simply.net">c0nst@money.simply.net</a>");
        doMatch("<a href="mailto:somebody@dev.com.ua">somebody@dev.com.ua</a>");
        doMatch("<a href="mailto:Name.Sur_name@gmail.com">Name.Sur_name@gmail.com</a>");
        doMatch("<a href="mailto:useR33@somewhere.in.the.net">useR33@somewhere.in.the.net</a>");
    }š</pre></span><div><span class="Apple-style-span" style="font-family: monospace; font-size: 12px; color: rgb(35, 35, 35); white-space: pre; ">}</span></div><div><span class="Apple-style-span" style="font-family: monospace; font-size: 12px; color: rgb(35, 35, 35); white-space: pre; ">îÅ × ÔÅÍÕ áêðé Á × ÔÅÍÕ ÒÅÇÕÌÑÒÎÙÈ ×ÙÒÁÖÅÎÉÊ.</span></div>
</div>