Paul Johnson wrote:
> On Tue, Apr 15, 2008 at 08:38:30PM +0100, Rob Dixon wrote:
>> Paul Johnson wrote:
>>> On Wed, Apr 16, 2008 at 12:11:20AM +0530, [EMAIL PROTECTED] wrote:
>>>
>>>> I need help in regular expression. I have string as follows.
>>>>
>>>> OMS.FD.08.03.000.14
>>>>
>>>> I need only OMS.FD.08.03.000 this much part of the string.i want to
>>>> exclude .14
>>> That's not much of a spec.  How far have you got?
>>>
>>> Perhaps one of these possibilities will help?
>>>
>>>  $_ = "OMS.FD.08.03.000";
>> It was 'OMS.FD.08.03.000.14'
> 
> The original was.  I was providing an (admittedly unlikely) potential
> solution.

No, the object data in the original post was different from what you
coded. I don't think you meant to correct his data - that would be a
little too presumptuous :)

> Followed by some more, which might have been more likely.
> 
>>>  s/.14//;
>>>  s/\.\d+$//;
>>>  s/\..*$//;
>>>  s/^((?:[^.*]\.){4}[^.]*).*/$1/;
>> All of those options will modify the object string, which is unlikely to
>> be what is wanted.
> 
> Which was sort of my point.  Who knows what was actually wanted?
> 
>> Without knowing the full range of possible strings, I suggest the
>> program below may help.
> 
> See, now you're playing too ;-)

Sure - the problem was understated, but all of your solutions modified
the object string when a simple regex with a capture could have provided
a solution with no side effects.

An analyst's job is to establish the problem as well as the solution,
not to invent possible problems.

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to