Re: reduce all spaces to one [message #176910 is a reply to message #176909] |
Sun, 05 February 2012 00:39 |
John
Messages: 18 Registered: September 2010
Karma:
|
Junior Member |
|
|
Am 05.02.2012 00:05, schrieb Thomas 'PointedEars' Lahn:
>
> I do not think you have fully understood what I have said (maybe you want to
> try posting to *de*.comp.lang.php instead?). *All* presented solutions so
> far, including yours and mine, are "'regex' solutions". But the set of
> characters that are replaced differs between them.
>
Thanks for the suggestions and advice : however I hope my english is
adequate enough to make myself understood in this NG :-))
>
> $words = str_split(' ', preg_replace('/\\s+/', ' ', $text));
>
I have the problem of 'filtering' a text file, exported from Excel as a
'Windows text file with <return>', containing <tabs> between numbers.
So, besides converting all comma to points, I have to get rid af all
<tabs> and after that, reduce all spaces between words to one space.
So far its working : I have used the preg_split first with /\t/ then
/\s+/ in two separate steps. No problem so far.
If they arise, I'll come back again.
>
> You might also want to exclude periods (`.') and other punctuation from
> words,
I can't. I need the numbers and they may be decimals with points.
> You might find [5] useful, in particular [6], for the next time that you
> post (translations are available there).
>
Thanks very much indeed for the most exhaustive answer ! I am happy
I've found this place.
Thanks and best regards to all who contributed to the thread.
John.
|
|
|