|
|
sybperl-l Archive
Up Prev Next
From: Monty Scroggins <Monty dot Scroggins at wcom dot com>
Subject: Re: splitting a field by an unrecognizable null field
Date: Sep 25 2000 5:10AM
Maybe you can split on \W (anything but a word character)..
Just a thought
Monty
----- Original Message -----
From: "Klein, Shoshana R"
To: "SybPerl Discussion List"
Sent: Sunday, September 24, 2000 8:55 PM
Subject: splitting a field by an unrecognizable null field
> 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
>
|