<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:courier,monaco,monospace,sans-serif;font-size:10pt"><div style="font-family: courier,monaco,monospace,sans-serif; font-size: 10pt;"><br>I think this is very close to what you want, except the first line of the output.<br><br><span style="font-weight: bold;">-> cat tmp.txt</span><br>Tree : This is a sentence, and a statement, about how<br>great trees are. Sky : This, on the other hand, is something cool<br>about the sky, sometimes blue, or not. AIR : AIR is sometime<br>breathable or not depending on where you are BlueBirds : Are cool<br>little birds with blue feathers.<br><br><span style="font-weight: bold;">-> perl -072 -ne 's/\n/ /gms; s/(\S+)(\s*:\s*)$/"\n\1,"/; print ' tmp.txt</span><br>"<br>Tree," This is a sentence, and a statement, about how great trees are. "<br>Sky," This, on the other hand, is something cool about the sky, sometimes
blue, or not. "<br>AIR," AIR is sometime breathable or not depending on where you are "<br><br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Mike Ferrari <mikeferrari8@yahoo.com><br>To: Chicago.pm chatter <chicago-talk@pm.org><br>Sent: Wednesday, March 26, 2008 10:02:57 AM<br>Subject: [Chicago-talk] Regex and the whitespace before it.<br><br>
Hi Everyone<br><br>I want to thank everyone for the good discussion on
this list recently, and Mike Fragassi for his help last year with
XML::Parser.<br><br>I have another stumper i am dealing with and need a
little help. My regex skills are weak, but i am reading up on regex
like a madman.<br>
<br>I have data like this...<br><br>Tree : This is a sentence, and a
statement, about how great trees are. Sky : This, on the other hand, is
something cool about the sky, sometimes blue, or not. AIR : AIR is
sometime breathable or not depending on where you are BlueBirds : Are
cool little birds with blue feathers.<br>
<br>And it goes on and on.. maybe not with the cool summertime content.. but you get my drift.. essentially its ..<br><br>subject : description of a subject. subject : description of a subject. subject : description of a subject. etc etc<br>
<br>I need to parse this and break it out into individual strings so i can print it to a csv file for easy spreadsheet reading.<br><br>subject : description of a subject. <br>Sky : This, on the other hand, is something cool about the sky, sometimes blue, or not.<br>
<br>I can split the data by : but that leaves the subject word "out" ..
and the next subject word "in", .. not every description ends with a
period either.. and commas and other junk are interspersed haphazardly in the
description ..<br>
<br>How can i split the string by the whitespace one word before the : ?<br><br>I have been playing with $` but not getting what i need.<br><br>Any ideas.<br><br clear="all">Thanks<br>Mike F<br clear="all"><font color="#888888"><br>
</font><br clear="all"><br>-- <br>/dev/mike0<br><br><a rel="nofollow" target="_blank" href="http://www.mikeferrari.com">http://www.mikeferrari.com</a>
</div><br></div></div></body></html>