PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Klein, Shoshana R" <Shoshana dot Klein at gs dot com>
Subject: splitting a field by an unrecognizable null field
Date: Sep 25 2000 1:55AM

Hi,
I'm trying to split a name field into first and last name, the input data
has the name as one field that appears to have a space in between the first
and last name.

I tried splitting on \t \s \b \w / / and it doesn't work.
any ideas how I can separate this field without knowing what kind of
character actually is there.
I'm not quite sure where the data came from, it could have been from a
massaged excel,word,
notepad etc file.

     $first, $last = split(/\b/, $name);
      print "b   first=$first last= $last name= $name \n";
     $first, $last = split(/\w/, $name);
      print "w   first=$first last= $last name= $name \n";
     $first, $last = split(/\t/, $name);
      print "tab first=$first last= $last name= $name \n";
     $first, $last = split(/ /, $name);
      print "blank  first=$first last= $last name= $name \n";
     $first, $last = split(/\s/, $name);
      print "s first=$first last= $last name= $name \n";
  
     ($first, $last) = split(/![a-z,A-Z]/, $name);
      print "nots first=$first last= $last name= $name \n";         


tHE OUTPUT LOOKS LIKE THIS
b   first= Karen Livings last= 3 name= Rachel Tippetts
w   first= Karen Livings last= 7 name= Rachel Tippetts
tab first= Karen Livings last= 1 name= Rachel Tippetts
blank  first= Karen Livings last= 2 name= Rachel Tippetts
s first= Karen Livings last= 2 name= Rachel Tippetts
nots first=Rachel Tippetts last=  name= Rachel Tippetts