JSFiddle - React, Tailwind, and code Playground

by rodrigonery

HTML

<!-- BootStrap do Twitter -->
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css" rel="stylesheet">
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet"><p>
<!-- // BootStrap do Twitter -->

<!-- Form -->
  <form class="well">
    <fieldset>
      <legend>Testador de Regex</legend> 
        <label>Digite aqui o formato a ser testado:</label>
          <input type="text" class="span3" id="texto" placeholder="Teste aqui sua data, cep, cpf..." /> 
          <span class="help-block">ex: [email protected], etc..</span> 
        <button class="btn btn-danger" type="submit" id="submit">TESTAR</button>
    </fieldset>
  </form>
<!-- // Form -->

JavaScript

// Minified Plugin by Nery
(function(a,b,c,d){a.fn.teste=function(b){return this.each(function(){var c=a(this),d=a("input:text").val();b.test(d)?alert("Verdadeiro"):alert("Falso")}),this}})(jQuery,window,document)
    
// Como usar o plugin
    
    $(function() {
    "use strict";
    var submit = $("#submit");
                                                                      
   submit.click(function(e) {
        e.preventDefault();
        self = $(this);
       
       // Coloque o regex que quer testar dentro dos parentesis abaixo..
        self.teste(/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.(com|net|com.br|info|com.us|net.br|blog.br|tv.br|tv)$/);
    });
});
                                          
/* 
  Aqui postei algumas expressões regulares antigas que você pode usar pra testar..
                                          
Testar Password:
/^[a-z0-9_-]{6,18}$/;

Testar Username:
/^[a-z0-9_-]{3,16}$/;  

Testar Hexadecimal:
/^#?([a-f0-9]{6}|[a-f0-9]{3})$/;
                                          
Testar se é uma Html tag:
/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/;
                                          
Testar se é um Ipv4:
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;

Testar url:
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
                                          
Testar Email:
/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/;

Testar Email:
/^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;                        
Criado por Rodrigo Nery
*/