I've been sitting on this for 2 days now, and still didn't find an effective way to do so. Lets say we have the string: <5629476219<421fsaas42f>14222<2412f2<2421savsar21>12vsaf21>412<<<142avsa1>1a24>421>421> The output I want: <562947621914222412421> Well, recursively there might be data inside <> brackets, it could consist of numbers and letters - but the first level consists only of numbers. I bolded out the data I want to extract. I want to do this in Python. The naive way is to implement a bracket stack of course (that way I'll know if I'm inside an inner bracket or I'm in the 1st level) - but it's very inefficient going char by char. I believe there is a good regex pattern I could use, but I haven't come up with something that works. Can some with enough experience with regex give a little help? Of course, other ideas except running char by char iteratively are welcome as well, run-time is important to me. Continue reading...