TheBobynator Posted February 25, 2009 Share Posted February 25, 2009 (edited) hi, is it possible to search in a txt file after a word and then i get the line number of the word which i searched. I search after the word mouse. txt file__________________________________ dog cat hourse mouse rabbit tiger _______________________________________ now must get the line number "4" help. thx Edited February 25, 2009 by TheBobynator Link to comment Share on other sites More sharing options...
Authenticity Posted February 25, 2009 Share Posted February 25, 2009 Dim $sText = 'Cat' & @CRLF & 'Dog' & @CRLF & 'Giraffa' & @CRLF & 'Bird' & @CRLF & _ 'Mesocricetus' & @CRLF & 'Parrot' & @CRLF & 'Etc..' Dim $aLines = StringRegExp($sText, '(?>[^\r]*)(?:\r\n|$)', 3) For $i = 0 To UBound($aLines)-1 If StringInStr($aLines[$i], 'Mesocricetus') Then ExitLoop Next ConsoleWrite('Found Mesocricetus on line: ' & $i+1 & @LF) Use StringSplit if you like, the line is not zero based. Link to comment Share on other sites More sharing options...
TheBobynator Posted February 25, 2009 Author Share Posted February 25, 2009 thx very much Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now