in reply to Refactoring Regular Expressions

I don't think it should be a question of refactoring the regexes. Instead, you should refactor the part that involves using "substr" in the first place.

Why are you using substr at all? There seems to be no need to do that, and if you don't use it, you'll only need the one regex (the first one) -- unless of course the data turns out to be malformed in some way.

But I would agree with the suggestion to use modules for this. In the long run, you'll be glad you did.