REGEX Tips
(?i) starts case-insensitive mode (?-i) turns off case-insensitive mode
(?i) starts case-insensitive mode (?-i) turns off case-insensitive mode
1 |
<span class="pun">(?:(?:</span><span class="pln">http</span><span class="pun">|</span><span class="pln">https</span><span class="pun">):</span><span class="pln">\/\/</span><span class="pun">)?(?:</span><span class="pln">www</span><span class="pun">.)?</span><span class="pln">facebook</span><span class="pun">.</span><span class="pln">com\/</span><span class="pun">(?:(?:</span><span class="pln">\w</span><span class="pun">)*#!</span><span class="pln">\/</span><span class="pun">)?(?:</span><span class="pln">pages\/</span><span class="pun">)?(?:[?</span><span class="pln">\w\-</span><span class="pun">]*</span><span class="pln">\/</span><span class="pun">)?(?:</span><span class="pln">profile</span><span class="pun">.</span><span class="pln">php\?id</span><span class="pun">=(?=</span><span class="pln">\d</span><span class="pun">.*)</span> |
1 2 3 |
jQuery.validator.addMethod( "date", function( value, element ) { return this.optional( element ) || /^(19|20)\d{2}\/(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])$/.test( value ); }, "Please enter date format eg.mm/dd/yyyy" ); |
PHP
1 2 3 4 5 6 7 8 9 10 11 |
<?php $line = "13/20/2017"; // perform a case-Insensitive search for the word "Vi" if (preg_match("/^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/", $line)) { print "Match found!"; }else{ print "No Match found!"; } ?> |