Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ip = '111.222.333.444';
- 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) ) {
- echo 'ip: ' . $match['1'] . (isset($match['2']) ? ' port: ' . $match['2'] : '');
- }
- (?:: #Match the :
- (?![7-9]dddd) #Ignrore anything above 7....
- (?!6[6-9]ddd) #Ignore anything abovr 69...
- (?!65[6-9]dd) #etc...
- (?!655[4-9]d)
- (?!6553[6-9])
- (?!0+) #ignore complete 0(s)
- (?<Port>d{1,5})
- )?
- if (preg_match(
- '/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]?)
- (?::
- (?![7-9]dddd) #Ignrore anything above 7....
- (?!6[6-9]ddd) #Ignore anything abovr 69...
- (?!65[6-9]dd) #etc...
- (?!655[4-9]d)
- (?!6553[6-9])
- (?!0+) #ignore complete 0(s)
- (?P<Port>d{1,5})
- )?
- b/x',
- $subject)) {
- # Successful match
- }
- 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
- [0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3}:[0-9]{5}
Add Comment
Please, Sign In to add comment