The ssh service runs on port 22, so :22 is both, a valid number of seconds and a valid port number.
Your second approach would work, but it would miss port :443 for https.
Maybe you can be more specific for the situations where a port number is to be expected.
In reply to Re: Exact Regex for port Number
by Corion
in thread Exact Regex for port Number
by theravadamonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |