Shell_Life,
based on my own experience, most of the OPs asking how to use regex and/or sed for editing start their queries with the very ambiguous definitions of the 'tasks at hand'. As solutions are proposed, in most cases (not all of them and not all the time) it becomes evident that a simply solutions (without considering the hypotheticals in the form of 'what if) will simply not scale. And the threads will go on and on with the numerous tweaks to the regex along the way.
As I said in most cases the OPs don't "see" the repetitive patterns and cannot identify the 'trends'. So I try to assume the "pattern" if I do see it and in most cases (once again - not all the cases and not all the time) it is what the OPs want.
Once again - "your mileage may vary". You can most certainly approach the answer differently like either your response (making no assumptions) or like what cfajohnson just posted (rephrasing the initial question with different 'twists" and answering them one-by-one in order and let the OP choose the interpretation of his/her/its original question for themselves). BTW, I do prefer the latter (but in most cases I simply don't have the patience to do it consistently) - thanks Chris.
It all comes down to the posting "style". If someone has the desired, the patience and the stamina to answer every OPs question in the very detailed manner - all the power to him/her - it will only benefit the greater community and these forums. I simply try to do my own best in the manner that I find fit based on 2 factors:
- time and availibility
- judgement call of the original posting - if I feel/see that the OP spent enought time and effort analyzing and phrasing his/her/its question in the detailed manner - it's a clear indication (at least to me) that the OP deserves a detailed thorough answer. On the other hand, if the question is vague (in my eyes), I make my own assumptions based on my own experience and post a 'quick and dirty' solution. In the latter case, the experience shows that most of the OPs are 'transient' and don't care about understanding the specifics of the solution and don't respond with more detailed questions.
Sorry for going on the tangent here.....