匹配一行中的第 n 个单词 [英] Match the nth word in a line

查看:31
本文介绍了匹配一行中的第 n 个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我使用的应用程序中,我无法选择匹配的组 1.

In the app I use, I cannot select a match Group 1.

我可以使用的结果是来自正则表达式的完整匹配.

The result that I can use is the full match from a regex.

但我需要第 5 个单词jumps"作为匹配结果而不是完整匹配The quick brown fox jumps"

but I need the 5th word "jumps" as a match result and not the complete match "The quick brown fox jumps"

^(?:[^ ]*\ ){4}([^ ]*)

The quick brown fox jumps over the lazy dog

这是一个链接 https://regex101.com/r/nB9yD9/6

推荐答案

它有效 https://regex101.com/r/pR22LK/2 与 PCRE.你的应用似乎不支持它,但我不知道它是如何工作的.我认为您必须提取数组中的所有单词,然后选择您想要的单词.– 多多 23 小时前

It works https://regex101.com/r/pR22LK/2 with PCRE. Your app doesn't seem to support it, but I don't know how it works. I think you have to extract all the words in an array then select the ones you want. – Toto 23 hours ago

您好 Toto,您的解决方案也适用于应用程序,例如 PCRE,谢谢!!!– gsxr1300 刚刚编辑

Hello Toto, your solution works in the the App too, like PCRE, thanks !!! – gsxr1300 just now edit

这篇关于匹配一行中的第 n 个单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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