Say I have an array of numbers: arr=[1, 2, 3, 4, 5, 4, 3, 2, 1].
Regular Regex has its basic units/literals as characters. I am wondering if there is a way to have "objects" as the basic unit, for an object [a,b]. 
Now I want to answer the question, "does arr contain at least 2 intervals of length 3 that have positive gradients?". I was thinking that I could mimic Regex by replacing characters with [a,b] objects, where a is the size of the interval and b is the function to run on that interval (gradient_pos). the function would return True or False depending on whether or not the condition was met. For example, to answer the above question, you would query:
[3,gradient_pos]{2,}
You will see that the syntax follows all the regex rules, except that rather than looking at characters, we are looking at [a,b] objects that effectively evaluate to True or False. The idea is that regex would try and match 2 or more intervals of length 3 that satisfy gradient_pos. Does that make sense? I know this is very abstract, but if anyone could help me out with achieving something like this, I'd greatly appreciate it!
Thanks!
 
    