FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » reduce all spaces to one
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: reduce all spaces to one [message #176911 is a reply to message #176910] Sun, 05 February 2012 01:56 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 2/4/2012 7:39 PM, John wrote:
> 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.
>

The /\s+/ will also get rid of tabs, converting all white space to a
single blank.

Perhaps a better option would be to export the file as a .csv and use
fgetcsv(). It will save you a lot of work.


>>
>> 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.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Check email
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 14:52:35 GMT 2024

Total time taken to generate the page: 0.05978 seconds