1 Replies - 5982 Views - Last Post: 11 January 2009 - 10:15 PM

#1 xesecre   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 32
  • Joined: 29-July 08

Perl counting columns, using regular expression to count tabs

Posted 11 January 2009 - 09:28 PM

Hello
I have been having a problem with tab delimited lists lately, when I process the list through perl since there are extra Line breaks that are not supposed to be there it messes the list up

example

name company address city st zip*
karl associated 110 south *Fargo nd 58102*

I put these asteriks in place where the Line breaks are so you can see what I mean, for some reason I have a line break in the middle of the row and this character shows up in the text file as a little black rectangle
after using regular expressions for LF CR and that type of thing I found out that if I remove just an LF it removes them all, seems this rectangle has a property of a regular line feed and I have been really thinking what would be the best way to just eliminate the one in the middle where you see word Fargo, I want that one gone or any of them gone until it gets to the last column Zip

here are my thoughts on this, could I somehow count the columns
use this as a variable and somehow put this in a regular expression so I could erase all the line breaks as long as they are before my last column
could I count tabs in the regular expression?

or should I take all line breaks out after counting how many tabs or words between tabs that I have in the header and use this to replace a LF after so many columns?

I am trying at first come up with a solution before I start to make a code
if I could have any hints tips, regular expressions or any advice from this point on what I am trying to do
perhaps there is a much easier way, I almost gave up but lately I really think that something can be done
thanks again
John

Is This A Good Question/Topic? 0
  • +

Replies To: Perl counting columns, using regular expression to count tabs

#2 KevinADC   User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 401
  • Joined: 23-January 07

Re: Perl counting columns, using regular expression to count tabs

Posted 11 January 2009 - 10:15 PM

I think removing all line feeds ( or replacing them with a space or tab or whataver is appropriate) is the best way to go, then add one where its needed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1