perl ?

Andy Harrison aharrison at gmail.com
Fri Jun 18 17:22:41 PDT 2004


On Fri, 18 Jun 2004 16:34:38 -0400, JJB <barbish3 at adelphia.net> wrote:
> 
> I have $email field that sometimes may not end with alpha character.
> 
> How would I code    if  (last position of $email != alpha) { replace
> last pos of $email with blank }
> 
> Or any other coding method to strip off non alpha from $email field
> if present.
> 
> Thanks
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> 

Something along the lines of:

my @foo = split( //, $email );

and then do one of these,

pop @foo unless $foo[-1] =~ /[a-zA-Z]/;

or to really want to replace it with a space,

$foo[-1] =~ " " unless $foo[-1] =~ /[a-zA-Z]

-- 
Andy Harrison


More information about the freebsd-questions mailing list