Code: Select all
The dog and the cat ran
The cat and the bird
The dog and the bird ran
The mouse and the cat ran
The dog and the mouse
Code: Select all
The dog and the cat ran
The cat and the bird
The dog and the bird ran
The mouse and the cat ran
The dog and the mouse
Code: Select all
Define File, KeyWord.s, String.s
Define NewList Row.s()
File = ReadFile(#PB_Any, "TextFile")
KeyWord = "dog"
If File
While Not Eof(File)
String.s = ReadString(File)
If Not FindString(String, KeyWord, #PB_String_NoCase)
AddElement(Row()) : Row() = String
EndIf
Wend
CloseFile(File)
EndIf
Code: Select all
s.s = "The dog and the cat ran" + #CRLF$ +
"The cat And the bird" + #CRLF$ +
"The dog And the bird ran" + #CRLF$ +
"The mouse And the cat ran" + #CRLF$ +
"The dog And the mouse" + #CRLF$
For i = 1 To CountString(s, #CRLF$)
sString.s = StringField(s,i, #CRLF$)
If Not FindString(sString,"dog") And Not FindString(sString,"Dog") ; Matchs Dog or dog
Debug sString
EndIf
Next
iRegex.i = CreateRegularExpression(#PB_Any, "[Dd]og") ; Matchs Dog or dog
For i = 1 To CountString(s, #CRLF$)
sString.s = StringField(s,i, #CRLF$)
If Not MatchRegularExpression(iRegex, sString)
Debug sString
EndIf
Next
Code: Select all
iRegex.i = CreateRegularExpression(#PB_Any, "\bdog\b", #PB_RegularExpression_NoCase)
; Matchs dog whatever letters case
; Matchs dog preceded and / or followed immediately (without space) by ,;. <tab> etc
; Does not match "dogs" "hotdog"