简体   繁体   English

正则表达式 - 提取单词和数字

[英]Regular Expression - Extract Words and number

So I'm using Regexextract in GoogleSheet to find the value for a big amount of data.所以我在 GoogleSheet 中使用 Regexextract 来查找大量数据的价值。 I have 2 problems I don't know to extract or what I did wrong.我有 2 个问题我不知道要提取或我做错了什么。 Feel free to point out my mistakes and help me with a solution.随时指出我的错误并帮助我解决问题。 Require: I need to extract the part number which format is ABCD#### or ABCD-#### which is is Upper character and numbers follow after, with or w/o "-", for example KTA1763 or SPD-4124 @ I use this formula: =Regexextract(A1,"([AZ]+-?[0-9]*)").FYI, the values I'm extracting, it could appear either at the beginning, middle or last.要求:我需要提取格式为 ABCD#### 或 ABCD-#### 的部件号,它是大写字符,后跟数字,带或不带“-”,例如 KTA1763 或 SPD-4124 @ 我使用这个公式:=Regexextract(A1,"([AZ]+-?[0-9]*)").FYI,我正在提取的值,它可能出现在开头、中间或最后。

1.First problem, I have the value as below: REACH TECH 223/224 list document for KTD2026BEWE-TR => Extract result: REACH [What I need: KTD2026] 1.第一个问题,我的值如下: REACH TECH 223/224 list document for KTD2026BEWE-TR => 提取结果:REACH [我需要什么:KTD2026]

2.I have the value as: information for Part number KTA1550EDS-TR => Extract result: P [What I need: KTA1550] 2.我的值为:零件号KTA1550EDS-TR的信息=>提取结果:P [我需要的:KTA1550]

Please let me know which part in the formula should I fix to have the final expected result.请让我知道我应该修复公式中的哪个部分以获得最终的预期结果。 Or how should I alter my formula for that matter, big thanks或者我应该如何改变我的公式,非常感谢

Try this in one cell .在一个单元格中尝试此操作。

=ArrayFormula(IF(A2:A="",,REGEXEXTRACT(REGEXEXTRACT(A2:A, ".+"&REGEXEXTRACT(A2:A, "[0-9]+")), ".+\s(.+)")))

在此处输入图像描述

go for: go 用于:

=INDEX(IFNA(REGEXEXTRACT(A1:A, "[A-Z]+\d+")))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM