我试图从惠普产品描述中过滤掉产品线和产品型号的信息
示例:
HP EliteDesk 800 G1 SFF (H3S08US#ABA)
HP Pro 3400 Series MT (H3S08US#ABA)
HP EliteBook 8460p (H3S08US#ABA)
预期产量:
Production line: EliteDesk
Production model: 800 G1
Production line: Pro
Production model: 3400 Series
Production line: EliteBook
Production model: 8460p
这是我现在所拥有的
product_line = re.search('([a-zA-Z]+) ([a-zA-Z]*\d+[a-zA-Z]*)', model).group(1)
product_model = re.search('([a-zA-Z]+) ([a-zA-Z]*\d+[a-zA-Z]*)', model).group(2)
但是,在第一个和第二个示例中,输出结果为8003400
有没有更好的方法过滤掉这些信息?非常感谢你们的到来
使用regex和split
你可以使用:
这里是Regex101.com上的example
它输出:
就用正则表达式
如果只需要regexp解决方案,可以使用:
就这么一分为二
相关问题 更多 >
编程相关推荐