in reply to url and arrays
Usually, I like to use one of the Regexp::Common::URI regular expressions. (There are also various other CPAN packages specifically written for dealing with URI's.) Basically, any time that I can shove a task off of my own plate, on to someone else’s, knowing also that this person has also written an entire test-suite and is delivering code that passes all those tests ... I’m gonna do that.
Now, if you do find yourself with the need to “roll your own” regexes, you’ll need to pay particular attention to the concept of greedy vs. non-greedy evaluation. If, for instance, you write a regex that uses something to grab “all the characters from a slash to the end of the string,” I might be wrong because my regex would be considered greedy, and it would match the longest string that it could ... thereby shoveling up additional slashes because the largest result would be obtained from matching the leftmost slash.
It is these subtleties, and others, that prompt me to seek out pre-tested work that comes neatly packaged in a convenient CPAN spray-bottle.