I am trying to find specific text and texts that comes before or after it. Ill give an example


Suppose I have a string of text that says: AnApplicationCanBeUsedToFindContinuationOfData

Suppose I want to find characters after the words "CanBe"

Example:

$something(AnApplicationCanBeUsedToFindContinuationOfData,CanBe,1,4)

This would return "Used" because there is only 1 (second paramter) instance of CanBe in the string and 4 letters after it is Used.

$something(AnApplicationCanBeUsedToFindContinuationOfData,tion,2,5) would return OfDat because 5 character after the 2nd instance of tion would be OfDat

$something(AnApplicationCanBeUsedToFindContinuationOfData,tion,2,-5) would return tinua because 5 character before the 2nd instance of tion would be tinua and 5 is negative.

Does anyone know how to write a script that does this? I cant seem to get anything like this to work. Help???