正则表达式来一个特定的词后,立即查找的单词 [英] Regex to find the word immediately after a particular word
本文介绍了正则表达式来一个特定的词后,立即查找的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用一个正则表达式字符串中一个特定的词后,立刻找到这个词。例如,如果单词是我的',
I want to find the word immediately after a particular word in a string using a regex. For example, if the word is 'my',
这是我的祈祷 - 祈祷
"This is my prayer"- prayer
这是我的书() - 书
"this is my book()"- book
是否有可能使用正则表达式?
Is it possible using regex?
推荐答案
正则表达式是
(?<=\bmy\s+)\p{L}+
\ p {L〕+
是一个字母序列。该 \ p {L〕
是统一code code与物业点,因此在任何语言的信相匹配。
\p{L}+
is a sequence of letters. The \p{L}
is a Unicode code point with the property "Letter", so it matches a letter in any language.
(小于?= \ BMY \ S +)
是向后断言,确保之前
(?<=\bmy\s+)
is a lookbehind assertion, that ensures thet word "my" is before
这篇关于正则表达式来一个特定的词后,立即查找的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文