Is there a nice way to evaluate a regular expression range, say, for a url such as
http://example.com/[a-z]/[0-9].htm
This would be converted into:
http://example.com/a/0.htm
http://example.com/a/1.htm
http://example.com/a/2.htm
...
http://example.com/a/9.htm
...
http://example.com/z/0.htm
http://example.com/z/1.htm
http://example.com/z/2.htm
...
http://example.com/z/9.htm
I’ve been scratching my head about this, and there’s no pretty way of doing it without going through the alphabet and looping through numbers.
Thanks in advance!
If you really need to do this, it’s not that hard to generate the strings using recursion. Here’s a snippet to do just that in Java:
(see full output)
This is a standard recursive tuple generator, but with some string infixing in between. It’s trivial to port to C#. You’d want to use a mutable
StringBuilder-like class for better performance.