Snipt.net is closing on December 31st, 2016

For more information, please visit this blog post.

snipt

Ctrl+h for KB shortcuts

Text only

HTTP-Date (HTTP/1.1 RFC-2616) regular expression validation (RFC-1123/RFC-850/ANSI C asctime)

(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:[0-2][0-9]|3[01]) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:[0-2][0-9]|3[01])-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?:[ 1-2][0-9]|3[01]) (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] \d{4})
https://snipt.net/embed/34a920c3bd75951b7aa4aff6c40a9f28/
https://snipt.net/raw/34a920c3bd75951b7aa4aff6c40a9f28/
34a920c3bd75951b7aa4aff6c40a9f28
text
Text only
1
2016-12-04T07:31:53
True
False
False
Apr 03, 2015 at 04:33 PM
/api/public/snipt/138884/
http-date-regular-expression-validation-rfc-1123rfc-850asctime-f64e6aa3
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:[0-2][0-9]|3[01]) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] GMT|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (?:[0-2][0-9]|3[01])-(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2} (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] GMT|(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (?:[ 1-2][0-9]|3[01]) (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] \d{4}) </span></pre></div> </td></tr></table>
"ANSI C", "RFC 1123", "RFC 2616", "RFC 850", 1123, 2616, 850, Date, HTTP, HTTP-Date, HTTP/1.1, RFC, asctime, expression, format, regular, validation

Text only

RFC 1123 regular expression validation

(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:[0-2][0-9]|3[01]) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] GMT
https://snipt.net/embed/eecad054c520ad40fa0ebef8843e2f90/
https://snipt.net/raw/eecad054c520ad40fa0ebef8843e2f90/
eecad054c520ad40fa0ebef8843e2f90
text
Text only
1
2016-12-05T04:10:20
True
False
False
/api/public/snipt/138883/
rfc-1123-regular-expression-validation-f4262fe2
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), (?:[0-2][0-9]|3[01]) (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} (?:[01][0-9]|2[0-3]):[012345][0-9]:[012345][0-9] GMT </span></pre></div> </td></tr></table>
"RFC 1123", 1123, Date, RFC, expression, regular, validation

PHP

Validation d'une URL

1
2
3
4
5
6
7
8
<?php 
 
function is_valid_url($url){
    $p1 ='/(http|https|ftp):\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i';
    return preg_match($p1, $url); 
}

?>
https://snipt.net/embed/0526fe2e783e23c0c0c4a2b6512d398d/
https://snipt.net/raw/0526fe2e783e23c0c0c4a2b6512d398d/
0526fe2e783e23c0c0c4a2b6512d398d
php
PHP
8
2016-12-04T12:35:22
True
False
False
/api/public/snipt/102287/
validation-dune-url
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">function</span> <span class="nf">is_valid_url</span><span class="p">(</span><span class="nv">$url</span><span class="p">){</span> </span><span id="L-4"><a name="L-4"></a> <span class="nv">$p1</span> <span class="o">=</span><span class="s1">&#39;/(http|https|ftp):\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i&#39;</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a> <span class="k">return</span> <span class="nb">preg_match</span><span class="p">(</span><span class="nv">$p1</span><span class="p">,</span> <span class="nv">$url</span><span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="p">}</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
url, validation

PHP

Validate if a string is a valid URL in PHP

1
2
3
4
<?php
if (filter_var($url, FILTER_VALIDATE_URL) !== false) {
  // echo('is valid!');
}
https://snipt.net/embed/59aaec0899ca3a6f5a750398f5121724/
https://snipt.net/raw/59aaec0899ca3a6f5a750398f5121724/
59aaec0899ca3a6f5a750398f5121724
php
PHP
4
2016-12-05T17:03:00
True
False
False
Jan 27, 2014 at 02:37 AM
/api/public/snipt/102097/
validate-if-a-string-is-a-valid-url-in-php
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span> <span class="p">(</span><span class="nb">filter_var</span><span class="p">(</span><span class="nv">$url</span><span class="p">,</span> <span class="nx">FILTER_VALIDATE_URL</span><span class="p">)</span> <span class="o">!==</span> <span class="k">false</span><span class="p">)</span> <span class="p">{</span> </span><span id="L-3"><a name="L-3"></a> <span class="c1">// echo(&#39;is valid!&#39;);</span> </span><span id="L-4"><a name="L-4"></a><span class="p">}</span> </span></pre></div> </td></tr></table>
php, url, validation

HTML

Custom messages for HTML5 validation

<input type="email" required oninvalid="this.setCustomValidity(this.willValidate?'':'your custom message')"/>
https://snipt.net/embed/b68952f317cdf5571028afe32638bfae/
https://snipt.net/raw/b68952f317cdf5571028afe32638bfae/
b68952f317cdf5571028afe32638bfae
html
HTML
1
2016-12-07T13:03:41
True
False
False
Aug 30, 2013 at 08:01 AM
/api/public/snipt/78031/
custom-messages-for-html5-validation
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;email&quot;</span> <span class="na">required</span> <span class="na">oninvalid</span><span class="o">=</span><span class="s">&quot;this.setCustomValidity(this.willValidate?&#39;&#39;:&#39;your custom message&#39;)&quot;</span><span class="p">/&gt;</span> </span></pre></div> </td></tr></table>
HTML5, validation

HTML

HTML5 Regular Expressions email validation

<input type="email" pattern="[^ @]*@[^ @]*" value="">
https://snipt.net/embed/c8184b363995c6ad6fcc91dea159f18d/
https://snipt.net/raw/c8184b363995c6ad6fcc91dea159f18d/
c8184b363995c6ad6fcc91dea159f18d
html
HTML
1
2016-12-10T09:43:18
True
False
False
May 28, 2013 at 12:57 PM
/api/public/snipt/62418/
html5-regular-expressions-email-validation
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="p">&lt;</span><span class="nt">input</span> <span class="na">type</span><span class="o">=</span><span class="s">&quot;email&quot;</span> <span class="na">pattern</span><span class="o">=</span><span class="s">&quot;[^ @]*@[^ @]*&quot;</span> <span class="na">value</span><span class="o">=</span><span class="s">&quot;&quot;</span><span class="p">&gt;</span> </span></pre></div> </td></tr></table>
"regular expressions", email, html5, regex, validation
Copyrighted, illegal, or inappropriate content? Email [email protected].