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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The regex would be
\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+)is a lookbehind assertion, that ensures thet word “my” is before