只在字符串后找到Word? [英] Only Find Word After a String?

查看:72
本文介绍了只在字符串后找到Word?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我在vb.net中使用正则表达式或正则表达式,需要学习如何使用前瞻只找到字符串后面的单词。



例如



这是文字字符串:狗





我的问题是,如果我写我的正则表达式如下



[这是文本字符串:] \w +



它会找到字符串和单词,但如果它们存在,它也会找到单词dog的其他匹配项。如果前面的字符串是这是文本字符串:,那么我只需要找到Dog这个词。



任何帮助或示例都将受到高度赞赏或者如果任何人都可以告诉我如何找到整个字符串但排除除狗这个词以外的所有内容



提前谢谢!!

Hello I am using regex or regular expressions in vb.net and need to learn how to use look ahead to only find the word that comes after a string.

for example

This is the text string: Dog


My problem here is that if i write my regular expression as follows

[This is the text string:] \w+

it will find the string and the word but it will also find other matches of the word dog if they exist. I need to only find the word "Dog" if the string before it is "This is the text string:"

Any help or examples would be greatly appreciated or if anyone can tell me how to find a entire string but exclude everything except the word "dog"

thank you in advance!!

推荐答案

I have solved this with look behind like so..

(?<=This is the text string (\w+)


我已经解决了这个看起来像这样的背后..



(?< =这是文本字符串:)(\ w +)
I have solved this with look behind like so..

(?<=This is the text string:)(\w+)


这篇关于只在字符串后找到Word?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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