help in reg. exp.
am 21.04.2008 13:17:02 von Irfan.Sayed
------_=_NextPart_001_01C8A3A1.3A855550
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi All,
=20
I have string like OMS.FD.08.03.000.0 Now my req. is that if the string
contains .0 at the end then I want to remove that .0 but if any other
digit is there other than .0 then don't do anything.
=20
For example: if string is : OMS.FD.08.03.000.0 then regular expression
should give OMS.FD.08.03.000
=20
But if string is : OMS.FD.08.03.000.18 then don't do anything=20
=20
Please help.
=20
Regards,
Irfan
=20
------_=_NextPart_001_01C8A3A1.3A855550--
Re: help in reg. exp.
am 21.04.2008 13:24:15 von chas.owens
On Mon, Apr 21, 2008 at 7:17 AM, wrote:
snip
> I have string like OMS.FD.08.03.000.0 Now my req. is that if the string
> contains .0 at the end then I want to remove that .0 but if any other
> digit is there other than .0 then don't do anything.
snip
What have you tried so far? You might consider reading the following
documentation on how regexes and substitutions work (hint: this is an
incredibly simple substitution):
perldoc perlretut
perldoc perlrequick
perldoc perlre
perldoc perlop
or
http://perldoc.perl.org/perlretut.html
http://perldoc.perl.org/perlrequick.html
http://perldoc.perl.org/perlre.html
http://perldoc.perl.org/perlop.html
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: help in reg. exp.
am 21.04.2008 14:05:22 von peng.kyo
On Mon, Apr 21, 2008 at 7:17 PM, wrote:
> Hi All,
>
>
>
> I have string like OMS.FD.08.03.000.0 Now my req. is that if the string
> contains .0 at the end then I want to remove that .0 but if any other
> digit is there other than .0 then don't do anything.
>
>
>
> For example: if string is : OMS.FD.08.03.000.0 then regular expression
> should give OMS.FD.08.03.000
>
try:
$str =~ s/\.0$//;
--
J. Peng - QQMail Operation Team
eMail: peng.kyo@gmail.com AIM: JeffHua
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/
Re: help in reg. exp.
am 21.04.2008 20:40:46 von Rob Dixon
Irfan.Sayed@t-systems.com wrote:
>
> I have string like OMS.FD.08.03.000.0 Now my req. is that if the string
> contains .0 at the end then I want to remove that .0 but if any other
> digit is there other than .0 then don't do anything.
>
> For example: if string is : OMS.FD.08.03.000.0 then regular expression
> should give OMS.FD.08.03.000
>
> But if string is : OMS.FD.08.03.000.18 then don't do anything
sub remdotzero {
my $str = shift;
$str =~ /(.*?)(?:\.0)?$/;
return $1
}
Rob
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/