首页 > 解决方案 > 选择特定文本的正则表达式

问题描述

<b>Dummy Alerts: </b>3/3Alerts have been addressed&#10; Question Alert: Have you had problems or are your volumes lower than normal?  " +
            "Yes Alert is closed on 01/09/2018 at 01:08 PM&#10; Question Alert: Have you been drinking more fluid? " +
            " Yes Alert is closed on 10/09/2019 at 01:08 PM&#10;&#10;Ram support visit performed 10/9/17,  Weight 90.2kg (dry). " +
            "TW achieved. No peripheral edema. BP within routine range per patient history. Urine output 1050ml. No PO fluid restriction at this time. " +
            "Patient did forget to bring in flow sheets.  Monitor UF trend with flow sheet review in one week. Michelle Mayhew Smith, RN."

我有很多类似的记录。

我要选择:-

 Ram support visit performed 10/9/17,  Weight 90.2kg (dry).
            TW achieved. No peripheral edema. BP within routine range per patient history. Urine output 1050ml. No PO fluid restriction at this time.
            Patient did forget to bring in flow sheets.Monitor UF trend with flow sheet review in one week. Michelle Mayhew Smith, RN.

在 C# 中使用正则表达式。

你能帮忙吗?

标签: c#regexc#-4.0c#-3.0

解决方案


using System;

class Program
{
    static void Main()
    {
        string dummyString = "<b>Dummy Alerts: </b>3/3Alerts have been addressed&#10; Question Alert: Have you had problems or are your volumes lower than normal?  " +
            "Yes Alert is closed on 01/09/2018 at 01:08 PM&#10; Question Alert: Have you been drinking more fluid? " +
            " Yes Alert is closed on 10/09/2019 at 01:08 PM&#10;&#10;Ram support visit performed 10/9/17,  Weight 90.2kg (dry). " +
            "TW achieved. No peripheral edema. BP within routine range per patient history. Urine output 1050ml. No PO fluid restriction at this time. " +
            "Patient did forget to bring in flow sheets.  Monitor UF trend with flow sheet review in one week. Michelle Mayhew Smith, RN.";

        // With String.Split    
        var splitted = dummyString.Split(new string[]{"&#10;"}, StringSplitOptions.None);
        Console.WriteLine(splitted[splitted.Length-1]);

        // With String.LastIndexOf & String.Substring
        int lastIndex = dummyString.LastIndexOf("&#10;");
        Console.WriteLine(dummyString.Substring(lastIndex+5));
    }
}

写了两次:

Ram 支持访问进行了 10/9/17,重量 90.2 公斤(干)。台湾实现了。无外周水肿。BP 在每个患者病史的常规范围内。尿量1050ml。目前没有 PO 流体限制。患者确实忘记带入流程图。在一周内通过流程图审查监控 UF 趋势。米歇尔·梅休·史密斯,注册护士。


推荐阅读