If I have some string data:
text = StringTake[ExampleData[{"Text", "DeclarationOfIndependence"}], 400]
"When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume, among the Powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the sepa"
This is what I use to find a specific pattern inside and grab a bit more data around it:
StringCases[text, (y__ /;StringLength[y] == 4) ~~ "entitle" ~~ x__ /;StringLength[x] == 5]
{"God entitle them"}
Are there any alternatives, desirably neater ones? Maybe something with regular expressions?
StringTake[text, First[StringPosition[text, "entitle"]] + {-4, 5}]
isn't neat? $\endgroup$