帮助我弄清楚如何处理文本
我有一个字符串,例如:“word1 number:word2”例如:“结果0:好”或“结果299:坏”
我需要打印未定义/低或高
当 string 为 null 时,打印 Undefined
当数字0-15时,打印Low
当数字 >15 时,打印 High
type GetResponse =
{
MyData: string voption
ErrorMessage: string voption }
val result: Result<GetResponse, MyError>
Run Code Online (Sandbox Code Playgroud)
然后我尝试:
MyData =
match result with
| Ok value ->
if (value.Messages = null) then
ValueSome "result: Undefined"
else
let result =
value.Messages.FirstOrDefault(
(fun x -> x.ToUpperInvariant().Contains("result")),
"Undefined"
)
if (result <> "Undefined") then
ValueSome result
else
errors.Add("We don't have any result")
ValueNone
| Error err ->
errors.Add(err.ToErrorString)
ValueNone
ErrorMessage …Run Code Online (Sandbox Code Playgroud)