java - RegEx to match a string between a set of words -
I am trying to match the words of a word between two words in a string. I am using Java Regx.
Input Text Expected output RegEx used I get output Which gives me all the words between fox and dog "fox" Following the word one or more all upper case words In the pursuit of these two words, I need to match all the words until I receive "dog" Also, in Capture Group 0 I Need to get the desired output. I can not use different capture groups. This is a limit to my application. Any help on this is greatly appreciated. You can use this regex: To use in other cases you can pass
The cunning fox jumping on the big dog and ran
large
( ? & lt; = (Fox [A-Z0-9] *)) (? s) (. *?) (? = \ sdog)
^. * Fox [A-Z0- 9 \ s] * (. *) Dogs * $
fox and
dog to your function.
Comments
Post a Comment