Guest User

Untitled

a guest
May 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. $ip = '111.222.333.444';
  2. if ( preg_match('/([0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}):?([0-9]{1,5})?/', $ip, $match) ) {
  3. echo 'ip: ' . $match['1'] . (isset($match['2']) ? ' port: ' . $match['2'] : '');
  4. }
  5.  
  6. (?:: #Match the :
  7. (?![7-9]dddd) #Ignrore anything above 7....
  8. (?!6[6-9]ddd) #Ignore anything abovr 69...
  9. (?!65[6-9]dd) #etc...
  10. (?!655[4-9]d)
  11. (?!6553[6-9])
  12. (?!0+) #ignore complete 0(s)
  13. (?<Port>d{1,5})
  14. )?
  15.  
  16. if (preg_match(
  17. '/b(?:(?: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]?)
  18. (?::
  19. (?![7-9]dddd) #Ignrore anything above 7....
  20. (?!6[6-9]ddd) #Ignore anything abovr 69...
  21. (?!65[6-9]dd) #etc...
  22. (?!655[4-9]d)
  23. (?!6553[6-9])
  24. (?!0+) #ignore complete 0(s)
  25. (?P<Port>d{1,5})
  26. )?
  27. b/x',
  28. $subject)) {
  29. # Successful match
  30. }
  31.  
  32. b(?:(?: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]?):d{1,5}b
  33.  
  34. [0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3}:[0-9]{5}
Add Comment
Please, Sign In to add comment