正则表达式跳过匹配中的空格 [英] Regex Skip space in match

查看:79
本文介绍了正则表达式跳过匹配中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一串数字代表 3 个不同的长度.我需要找出字符串中的第二个长度,但找不到从匹配中排除空格的方法.这是字符串的示例.它总是在点之后但在它变化之前有 6 位数字.在这种情况下,我需要完全匹配 907.086614.

I have a string of digits that represent 3 different lenghts. I need to pick out the second length in the string but can't find away to exclude the white space from the match. Here is an example for the string. It has always 6 digits after the dot but before it vary. In this case it is 907.086614 that I need to match exactly.

1417.322835 907.086614 2.267717

^\s(\d+\.\d{6})

我在后面玩了不同的外观,但无法排除空白.

I've played around with different look behind but can't get it to exclude the white space.

推荐答案

你可以试试这个

(?<=\s)(\d+\.\d{6})(?=\s)

参见演示

但如果你仍然想使用你的模式,删除行首锚^并匹配group 1

But if you still want to use your pattern, remove the begin of line anchor ^ and match group 1

\s(\d+\.\d{6})

参见演示

这篇关于正则表达式跳过匹配中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆