简体   繁体   English

Javascript正则表达式每两组数字匹配一次>字母和数字?

[英]Javascript regex match every two groups of numbers > letters and numbers ?

Trying to create a regex to: 尝试创建正则表达式以:

• To get any number or multiple numbers first provided there's no spacing •要首先获取任何数字或多个数字,请确保没有空格

• Then select a group of letters and numbers after any space. •然后在任意空格后选择一组字母和数字。 (Numbers optional) (数字可选)

This is currently working only when the groups of letters and numbers ends in a number 当前仅在字母和数字组以数字结尾时有效

This is my regex - /(\b\d+\s+([a-z+d])+\d+\b)|(\b\d+\s+([a-z+d])+\b)/ig

This is my test string: 这是我的测试字符串:

5 CF377A 
4
0 0CF377

At the moment its just currently selecting 目前,它当前正在选择

0 0CF377

The result I need is 我需要的结果是

5 CF377A 
0 CF377

Link to my regular expression - Regex expression 链接到我的正则表达式-正则表达式

Any help please ? 有什么帮助吗?

This captures the visible use-cases you've provided, but I'm not sure it passes all the requirements of your written description: 这捕获了您提供的可见用例,但是我不确定它是否满足您书面说明的所有要求:

(^\d+ +[a-z0-9]+)

Regex101 Regex101

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

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