I don't know why I'm getting that Exception on the List.filter part of the following code:
pdfLinks |> List.filter(fun x -> x.Contains("shop")) |> List.iter (printfn "%s")
pdfLinks is of type "string list" and it is populated with tons of strings that contain the word "shop".
It works ok in F# Interactive with a dummy list. The original one has been generated by parsing an HTML file but inspecting it by a watch shows it has desired values of the desired type.
Any idea what may be happening?
Thanks!
Try adding a call to System.String.IsNullOrEmpty
into your List.filter
and see if it fixes the problem:
pdfLinks
|> List.filter(fun x ->
(not <| System.String.IsNullOrEmpty x) &&
x.Contains("shop"))
|> List.iter (printfn "%s")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With