Regular expressions are suited to this problem:

Code:
on *:text:*:#:{
  var %regex = /(\d+\.\d+\.\d+\.\d+):(\d+)/S
  if ($regex($1-,%regex)) {
    var %ip = $regml(1), %port = $regml(2)
    echo -ag %ip :: %port
  }
}