Advertisement
Fray117

Extract IP Using Regex

Sep 9th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.21 KB | None | 0 0
  1. <?php
  2. $subject = '127.0.0.1 192.168.0.1-10.10.0.25';
  3. preg_match_all('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $subject, $matches);
  4. for ($i=0; $i < sizeof($matches[0]); $i++) {
  5.   print $matches[0][$i].'<br>';
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement