in reply to Re: To split with spaces
in thread To split with spaces

Firstly, thank you for your kind and smart answer.

You are right data is not obvious, sorry for this, I am not familiar with html codes. My input data is exactly as you predicted:

1234 2321 0 45 1st 2122 sdsa 0 0 34 2313 dsad 43 2nd 1232 ffff 0 0 1st 3213 sadf 0 34 2133 dada 0 2nd

As it is seen, there is different number of spaces between columns. So /\s/ is not working as well as /\s+/ is not working, because some columns have whitespace characters. Also substr function does not work due to same reason. Substr does not see whitespace character and passes to next column. I hope told my problem clearly:)

Replies are listed 'Best First'.
Re^3: To split with spaces
by Cristoforo (Curate) on Aug 05, 2013 at 01:50 UTC
    To answer your question, it is necessary to know more about your data. There are 6 columns and in your sample the third and fourth columns are 0 or blank. Is it possible that they could be a 2 or 3 digit number, like 33 or 123? Is the fifth column always a 2 digit number like 45, 34, 43... or could it be 1 digit (or 3 digits)? Its hard to tell with this data whether fields fill in from the left or right.

    And I'm guessing that the leading whitespace before the 1st column isn't really there, but is just the way you pasted it in.

      This is a small piece example data of our real data which is a telecommunication company parameters. So yes, third and fourth columns can also be between 0-100; and fifth column can be 0-300. Sequenly, from third column to last column, there can be blanks. Finally, leading whitespace before the 1st column isn't really there. Please help me, I should split those columns exactly. Problem I cannot pick up blanks, instead of that I can pick up next columns' values. That s the point. Substr or solutions that given from are not working.

        Please just give examples of data that aren't handled by the given solutions. People can only work with what you give them. Those solutions worked for the data you presented, so if they don't work for your entire sample, you failed to provide enough data to fully define the problem. Please help us.