Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Checks whether 'word' is in 'text', but not inside a word.
- let isIn (text: string) (word: string) =
- let isSep c = not (Char.IsLetterOrDigit(c))
- let mutable index = 0
- let mutable cont = true
- while cont && index <> -1 do
- index <- text.IndexOf(word, index, StringComparison.CurrentCultureIgnoreCase)
- if index <> -1 then
- if (index = 0 || isSep text.[index - 1]) && (index + word.Length = text.Length || isSep text.[index + word.Length]) then
- cont <- false
- else
- index <- index + 1
- not cont
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement