Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active September 5, 2020 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbvf50mobile/0ef7148908844a5d5f86b3f3cfd93f39 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/0ef7148908844a5d5f86b3f3cfd93f39 to your computer and use it in GitHub Desktop.
Just PHP FUN 095.
<?php
# https://www.codewars.com/kata/567fe8b50c201947bc000056 Regexp Basics - is it IPv4 address?
function ipv4_address($address){
$number = '(\d|([1-9]\d)|(1[0-9]\d)|(2[0-4]\d)|(25[0-5]))';
$dot_numbers = '(\.'.$number.'){3}';
$regex = '/^'.$number.$dot_numbers.'\z/';
return (bool) preg_match($regex,$address);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment