Re: Trimming Leading and Trailing Whitespaces

2002-10-31 Thread Richard Lippmann
At 12:44 30.10.2002 -0500, Stephens, Wes (N-Sybase) wrote:

Is there a string manipulation function to automatically trim leading and
trailing whitespaces?


No, but do it with regex:

$string =cat and dog   ;
# trim beginning ws
$string =~ s/^\s+//;
# trim ending ws
$string =~ s/\s+$//;


Greetings from Bavaria, Germany
Horshack


--
Richard Lippmann, Findus Internet-OPAC
Findus, see http://www.hultsfred.de
Private, see http://lena.franken.de

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Trimming Leading and Trailing Whitespaces

2002-10-31 Thread Carl Jolley

On Wed, 30 Oct 2002, [iso-8859-1] Burak Gürsoy wrote:

 $string =cat and dog   ;
 $string =~ s,^\s+(.+?)\s+$,$1,;
 print $string;

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:perl-win32-users-admin;listserv.ActiveState.com]On Behalf Of
 Stephens, Wes (N-Sybase)
 Sent: Wednesday, October 30, 2002 7:44 PM
 To: ActivePerl (E-mail); Perl-Win32-Users (E-mail)
 Subject: Trimming Leading and Trailing Whitespaces


 Is there a string manipulation function to automatically trim leading and
 trailing whitespaces?

 For example:

  Problem:
  $string =cat and dog   ;

  Objective:
  $string = cat and dog;


Of course your regex won't work on a String unless it has both leading
AND trailing white space. To make it handle those situations as well you
would need to change it to:

$string=~s/^\s*(.+?)\s*$/$1;

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Trimming Leading and Trailing Whitespaces

2002-10-30 Thread Stovall, Adrian M.
$string = cat and dog;
$string =~ s/^\s+(.*)\s+$/$1/;


 -Original Message-
 From: Stephens, Wes (N-Sybase) [mailto:wes.stephens;lmco.com] 
 Sent: Wednesday, October 30, 2002 11:44 AM
 To: ActivePerl (E-mail); Perl-Win32-Users (E-mail)
 Subject: Trimming Leading and Trailing Whitespaces
 
 
 Is there a string manipulation function to automatically trim 
 leading and trailing whitespaces?
 
 For example:
 
  Problem:
  $string =cat and dog   ;
 
  Objective:
  $string = cat and dog;
 
 
 Thanks,
 Wes
 
 ___
 Perl-Win32-Users mailing list 
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Trimming Leading and Trailing Whitespaces

2002-10-30 Thread mgfranz
Doesn't Perl have Trim function?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:perl-win32-users-admin;listserv.ActiveState.com]On Behalf Of
Burak Gürsoy
Sent: Wednesday, October 30, 2002 10:07 AM
To: Stephens, Wes (N-Sybase); ActivePerl (E-mail); Perl-Win32-Users
(E-mail)
Subject: RE: Trimming Leading and Trailing Whitespaces


$string =cat and dog   ;
$string =~ s,^\s+(.+?)\s+$,$1,;
print $string;

-Original Message-
From: [EMAIL PROTECTED]
[mailto:perl-win32-users-admin;listserv.ActiveState.com]On Behalf Of
Stephens, Wes (N-Sybase)
Sent: Wednesday, October 30, 2002 7:44 PM
To: ActivePerl (E-mail); Perl-Win32-Users (E-mail)
Subject: Trimming Leading and Trailing Whitespaces


Is there a string manipulation function to automatically trim leading and
trailing whitespaces?

For example:

 Problem:
 $string =cat and dog   ;

 Objective:
 $string = cat and dog;


Thanks,
Wes

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Trimming Leading and Trailing Whitespaces

2002-10-30 Thread Joseph P. Discenza
[EMAIL PROTECTED] wrote, on Wednesday, October 30, 2002 1:11 PM
: Doesn't Perl have Trim function?

Obviously you're confusing Perl with VB. B^)

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:jdiscenza;carletoninc.com
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! * 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Trimming Leading and Trailing Whitespaces

2002-10-30 Thread mgfranz
Oh how true... Where are my manners... ;-)

-Original Message-
From: Joseph P. Discenza [mailto:jdiscenza;carletoninc.com]
Sent: Wednesday, October 30, 2002 10:52 AM
To: [EMAIL PROTECTED]; 'Perl-Win32-Users (E-mail)'
Subject: RE: Trimming Leading and Trailing Whitespaces


[EMAIL PROTECTED] wrote, on Wednesday, October 30, 2002 1:11 PM
: Doesn't Perl have Trim function?

Obviously you're confusing Perl with VB. B^)

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:jdiscenza;carletoninc.com
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! * 


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs