I need a regex that gives me the word before and after a specific word, included the search word itself.
Like: "This is some dummy text to find a word" should give me a string of "dummy text to" when text is my search word.
Another question, it's possible that the string provided will contain more then once the search word so I must be able to retrieve all matches in that string with C#.
Like "This is some dummy text to find a word in a string full with text and words"
Should return:
- "dummy text to"
- "with text and"
EDIT:
Actually I should have all the matches returned that contain the search word.
A few examples:
Text is too read. -> Text is
Read my text. -> my text
This is a text-field example -> a text-field example
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…