Code:
on 1:text:!search *:#mychannel: {
  var %search = $2
  var %lines = $lines(database.txt)
  var %currentline = 1
  var %total = 0
  while (%currentline <= %lines) {
    var %data = $read(database.txt,w,* $+ %search $+ *-*,%currentline)
    if (%data != $null) {
      write temp.txt %data
      inc %total
      var %currentline = $readn
    }
    inc %currentline
  }
  write temp.txt %total found.
  play $chan temp.txt 1500
  .remove temp.txt
}


That code will allow you to do what you want.

Examples:

Text file includes:

this is a test - 123.345.567.789
this is not a test - 234.546.123.56
neither is this - 546.234.123.64
44 but this is a test - 354.78.23.1
487 - 784.354.487.64

!search this
* returns the first 4 lines

!search test
* returns lines 1,2,4

!search 4
* returns lines 4,5

As a note, however, your first section cannot contain a hypen in it like this:

let's-go-do-this - 234.36.123.34

If you want to allow hyphens in the first section, change the - divider between the two sections to something that won't be used in the first section and then change the hyphen in *-* to whatever you're using.