Hello. So I am messing with a function that will randomize sub strings in a string.
I went to the <park, bar, church> and ordered a cheeseburger.
If I wanted to, I could make a list with these strings and call it place, so I can now do the following.
I went to the <place> and ordered a cheeseburger.
Now let's say I want to have more than 1 layer of randomization at a time.
I went to the <place> and bought a <<food>, <computer>, <game>, <car>>, and it was great.
This makes no sense, but not the point.
So I have a function using re.split to find instances of the less and grater than signs and parsing them into a list.
However, that doesn't work with multiple layers. Instead of choosing one of the 4 lists and only randomizing that 1 list, it randomizes all 4 lists, then chooses. This is great if I want to see every path that it randomized, but in this case, I don't care about that, so I do not want it to waste extra time and randomization cycles that won't be seen.
I have determined re.split can not help with this, and what I need is a character mapping for every instance of the less than and grater than signs with the following 4 values.
The symbol found.
The level of the instance, aka the number of less than or greater than signs in a row without the other symbol closing the level.
The number of the instance in the current level, aka levels can vary through out the string, and the instance will ignore it.
And the position in the string the instance occurs.
This would be a whole module on its own. Organizing the data, writing functions for adding and subtracting levels, finding instances and levels, etc.
So I was wondering if there is a module or a library that uses regular expressions that already has a character mapping system like I have described. I can't be the first person who has needed this.
If there is a much simpler way than needing this whole system, please let me know.
If not, at least this would be an interesting challenge to create. But I figured I would ask here to save my time before I dive into this.