首页 > 其他分享 >字符串分割匹配

字符串分割匹配

时间:2023-11-16 10:02:48浏览次数:30  
标签:分割 used 匹配 name IV device 字符串 Catheter GPC

Infant Feeding Tube-It is used for neonates and paediatric nutritional feeding,Foley Balloon Catheter(GPC Foley Balloon Catheter)-It is a urinary tract catheter used for short term urine drainage,Safety IV Cannula(GPC Safety IV Cannula)-Safety IV Cannula is used to provide access in to the peripheral vascular system for the administration of fluids and drugs and for withdrawal of blood. Safety IV Cannula is used to deliver IV Fluids and medicines in to circulating system. The product has integrated passive safety features to cover the needle after use to prevent the accidental needle prick injuries.,IV Flow Regulator(GPC IV Flow Regulator)-It is used to deliver accurate volume of IV fluid and medicines into human circulating system.,IV Infusion Set(GPC IV Infusion Set)-The Infusion Sets are used only for gravity feed to administer Intravenous fluid and medicines into human circulating system by using intravenous catheter or cannula. ,3 Way Stop Cock(GPC 3 Way Stop Cock)-It is used for pressure infusion and blood pressure monitoring,Male External Catheter(GPC Male External Catheter)-It is used for urine incontinence in male patient,Nasal Oxygen Catheter(GPC Nasal Oxygen Catheter)-It is used for efficient administration of oxygen for greater comfort of patient,IV Cannula-The product is used to deliver Intravenous fluid and medicines into human circulating system and for withdrawal of blood.,Mucus Extractor-It is used for aspiration of secretion from oropharynx in newly born babies,Tracheostomy Tube-It is used to maintain patient airway through tracheostomy to mechanically ventilated patient.
理解这段话的意思,其中包含了多组Device Name(Brand Name)-Intended Use信息,其中某些组缺失了Brand Name信息,请把他分成多组以{device_name:device_name,brand_name:brand_name,intended_use:intended_use}的格式返回每组信息组成的列表,brand_name缺失的以空字符串代替,给出相关的python代码,

 

以下是将所提供的文本分组为Device Name、Brand Name和Intended Use的Python代码:

text = "Infant Feeding Tube-It is used for neonates and paediatric nutritional feeding,Foley Balloon Catheter(GPC Foley Balloon Catheter)-It is a urinary tract catheter used for short term urine drainage,Safety IV Cannula(GPC Safety IV Cannula)-Safety IV Cannula is used to provide access in to the peripheral vascular system for the administration of fluids and drugs and for withdrawal of blood. Safety IV Cannula is used to deliver IV Fluids and medicines in to circulating system. The product has integrated passive safety features to cover the needle after use to prevent the accidental needle prick injuries.,IV Flow Regulator(GPC IV Flow Regulator)-It is used to deliver accurate volume of IV fluid and medicines into human circulating system.,IV Infusion Set(GPC IV Infusion Set)-The Infusion Sets are used only for gravity feed to administer Intravenous fluid and medicines into human circulating system by using intravenous catheter or cannula. ,3 Way Stop Cock(GPC 3 Way Stop Cock)-It is used for pressure infusion and blood pressure monitoring,Male External Catheter(GPC Male External Catheter)-It is used for urine incontinence in male patient,Nasal Oxygen Catheter(GPC Nasal Oxygen Catheter)-It is used for efficient administration of oxygen for greater comfort of patient,IV Cannula-The product is used to deliver Intravenous fluid and medicines into human circulating system and for withdrawal of blood.,Mucus Extractor-It is used for aspiration of secretion from oropharynx in newly born babies,Tracheostomy Tube-It is used to maintain patient airway through tracheostomy to mechanically ventilated patient."  
  
devices = []  
for item in text.split(","):  
    device = {}  
    if "(" in item and ")" in item:  
        device_name = item.split("(")[0].strip()  
        brand_name = item.split("(")[1].split(")")[0].strip()  
        intended_use = item.split(")")[1].strip("-")  
    else:  
        device_name = item.split("-")[0].strip()  
        brand_name = ""  
        intended_use = item.split("-")[1].strip()  
    device["device_name"] = device_name  
    device["brand_name"] = brand_name  
    device["intended_use"] = intended_use  
    devices.append(device)  
  
print(devices)  

 

输出结果:

[{'device_name': 'Infant Feeding Tube', 'brand_name': '', 'intended_use': 'It is used for neonates and paediatric nutritional feeding'}, {'device_name': 'Foley Balloon Catheter', 'brand_name': 'GPC Foley Balloon Catheter', 'intended_use': 'It is a urinary tract...'}, {'device_name': 'Tracheostomy Tube', 'brand_name': '', 'intended_use': 'It is used to maintain patient airway through tracheostomy to mechanically ventilated patient.'}]  

 

标签:分割,used,匹配,name,IV,device,字符串,Catheter,GPC
From: https://www.cnblogs.com/avivi/p/17835531.html

相关文章

  • 将字符串转换为uniqueidentifier时失败
    MicrosoftSQLServerManagementStudioExpress不支持表字段uniqueidentifier插入未指定值启用默认值。未指定时会报“将字符串转换为uniqueidentifier时失败”//2008的MSSM不支持下面的带引号,前者可以,代价是默认值是字符串转换失败了这是一个小坑,正常的要将引号去掉,Po......
  • c语言 常量字符串及其初始化
    @TOC前言一、常量字符串:常量字符串:需用双引号包着。例如:"hello","你好".常量字符串的本质就是字符数组,该字符串就是数组的名字。访问常量字符串的个元素:"hellowyy"[0]"hellowyy"[1]"hellowyy"[2]......访问各元素可以输出,但是不能赋值修改,因为这是常量字符。常量......
  • 统计字符串中每个单词出现的次数
    defcount_words(string):words=string.split()word_count={}forwordinwords:ifwordinword_count:word_count[word]+=1else:word_count[word]=1returnword_countstring="Iloveprogramming.Programmingisfun!"......
  • 统计字符串中每个单词出现的次数
    defcount_words(string):words=string.split()word_count={}forwordinwords:ifwordinword_count:word_count[word]+=1else:word_count[word]=1returnword_countstring="Iloveprogramming.Programmingisfun!"......
  • KET.Application 报错:pywintypes.com_error: (-2147221005, '无效的类字符串', None,
    电脑突然有一天调用KET.Application总是报错,代码:importwin32com.clientxcl=win32com.client.DispatchEx("KET.Application")xcl.Quit()报错:pywintypes.com_error:(-2147221005,'无效的类字符串',None,None)WIN11系统,最新版WPSAI,之前用的好好的,不知道最近卸载了......
  • 9--844. 比较含退格的字符串
    给定 s 和 t 两个字符串,当它们分别被输入到空白的文本编辑器后,如果两者相等,返回 true 。# 代表退格字符。注意:如果对空文本输入退格字符,文本继续为空。 示例1:输入:s="ab#c",t="ad#c"输出:true解释:s和t都会变成"ac"。示例2:输入:s="ab##",t="c#d#"输......
  • split是对字符串的分割,而10.42编译器自动类型推断中应该是double类型的
    ceil的英文意义是天花板,该方法就表示向上取整,Math.ceil(11.3)的结果为12,Math.ceil(-11.3)的结果是-11;floor的英文意义是地板,该方法就表示向下取整,Math.floor(11.6)的结果为11,Math.floor(-11.6)的结果是-12;最难掌握的是round方法,它表示“四舍五入”,算法为Math.floor(x+0.5),即将......
  • 正则表达式中的小括号"()"。是代表分组的意思。 如果再其后面出现\1则是代表与第一个
    以下代码的执行后,str的值是:varstr="Helllloworld";str=str.replace(/(l)\1/g,'$1');AHeloworldBHelloworldCHellloworldDHelllloworld正确答案:B对于正则表达式/(l)\1/g,其中(l)是第一个分组,\1指向第一个分组,即\1重复了第一个分组的内容,所以该正则表达式......
  • SQLSERVER 2016新建订阅,连接发布服务器时报错“设置连接字符串后无法更改或读取属性 P
    被此问题困扰许久,查遍全网也没有查到合适的解决方案。特此记录,希望帮到需要的人。SQLSERVER2016新建订阅,连接发布服务器时报错“设置连接字符串后无法更改或读取属性Password。(Microsoft.SqlServer.ConnectionInfo)”===================================设置连接字符串......
  • Java中for循环每次都通过list.size、str.length、length()获取数组或者字符串的长度是
    最近看到有同事在使用for循环的时候首先会将数组或者字符串的长度赋值给一个变量;在网上查了一下说是这样可以节约资源的消耗,真实的情况又是如何?让我们看下他们的源码来分析。1.将数组的长度赋值给变量lenList<Integer>list=newArrayList<Integer>();list.add(......