You can remove the whitespace at the end of a line with this regex...

$text =~ s/\s+$//;

It matches one or more whitespace chars at the end of the line and replaces
them with nothing.

Rob

-----Original Message-----
From: Richard Pfeiffer [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 18, 2002 2:56 PM
To: [EMAIL PROTECTED]
Subject: regular expressions in rindex function


Good Afternoon,

Wondering if anyone could help me with this or
enlighten me on another way to go about it.

I have a string that has various white space
(tabs, spaces, etc) at the end of it.  I want to
find the last real char [0-9a-zA-Z] and then use
chop or chomp to remove the whitespace.

I've tried:
rindex($file, "t");  
which of course works if the last char is a 't',
but I certainly cannot always be assured of this.

However, none of the following word char
expressions are working:
rindex($file, "/[0-9a-zA-Z]/");
rindex($file, /[0-9a-zA-Z]/);
rindex($file, [0-9a-zA-Z]);
rindex($file, /[\w]/);
.....so either I'm doing it wrong or I can't use a
regular expression within rindex.  (My vote goes
for the former!)

Thanks!
-R

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to