reg ex

reg ex

am 15.04.2008 20:41:20 von Irfan.Sayed

------_=_NextPart_001_01C89F28.4C034F58
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi All,

=20

I need help in regular expression. I have string as follows.

=20

OMS.FD.08.03.000.14

=20

I need only OMS.FD.08.03.000 this much part of the string.i want to
exclude .14

=20

Please help.

=20

Regards,

Irfan

=20


------_=_NextPart_001_01C89F28.4C034F58--

Re: reg ex

am 15.04.2008 21:03:47 von Paul Johnson

On Wed, Apr 16, 2008 at 12:11:20AM +0530, Irfan.Sayed@t-systems.com wrote:

> Hi All,

Hello

> 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
>
> Please help.

That's not much of a spec. How far have you got?

Perhaps one of these possibilities will help?

$_ = "OMS.FD.08.03.000";
s/.14//;
s/\.\d+$//;
s/\..*$//;
s/^((?:[^.*]\.){4}[^.]*).*/$1/;

--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: reg ex

am 15.04.2008 21:38:30 von Rob Dixon

Paul Johnson wrote:
>
> On Wed, Apr 16, 2008 at 12:11:20AM +0530, Irfan.Sayed@t-systems.com 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'

> 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.

Without knowing the full range of possible strings, I suggest the
program below may help.

Rob


use strict;
use warnings;

my $str = 'OMS.FD.08.03.000.14';

if ($str =~ /(.*)\./) {
print $1;
}


--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: reg ex

am 15.04.2008 22:08:12 von Paul Johnson

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, Irfan.Sayed@t-systems.com 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.

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 ;-)

--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: reg ex

am 16.04.2008 01:31:36 von Rob Dixon

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, Irfan.Sayed@t-systems.com 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: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: reg ex

am 16.04.2008 11:09:37 von Paul Johnson

On Wed, Apr 16, 2008 at 12:31:36AM +0100, Rob Dixon wrote:
> 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, Irfan.Sayed@t-systems.com 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 :)

My point, which was obviously not well made (twice!), was that given the
minimal requirement

> >>>> I need only OMS.FD.08.03.000 this much part of the string.

a sort of Reductio ad absurdum argument leads to a solution of

> >>> $_ = "OMS.FD.08.03.000";

As such I should probably have given the solution last on my list, but that
would have entailed applying some sort of likeliness ordering on the list,
which I didn't really feel like doing.

In any case, perhaps Irfan would like to clarify his intent and let us know
which particular parts of the problem are causing him problems?

> 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.

You are correct. My re-reading of the original post still suggests that
modifying the string is the most likely requirement, but that's hardly
important any more. And both of us have wasted too much time on this already,
for which I apologise.

Over to you, Irfan.

--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/