Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #4727

Re: reduce all spaces to one

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail
Content-Type text/plain; charset="ISO-8859-1"
Message-ID <2279559.TulgWSeKXN@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Reply-To Thomas 'PointedEars' Lahn <php@PointedEars.de>
Organization PointedEars Software (PES)
Date Sun, 05 Feb 2012 03:15:22 +0100
User-Agent KNode/4.4.11
Content-Transfer-Encoding 7Bit
Subject Re: reduce all spaces to one
Newsgroups comp.lang.php
References <jghb1o$62h$1@speranza.aioe.org> <jghd0m$tvr$1@dont-email.me> <jghen802gga@news1.newsguy.com> <9p2tqsF5llU1@mid.uni-berlin.de> <jghhqd$nh0$1@speranza.aioe.org> <3604821.WhU2xvQL5g@PointedEars.de> <jgk7qi$rgb$1@speranza.aioe.org> <1669543.FqOfKyIYee@PointedEars.de> <jgkj4t$j9l$1@speranza.aioe.org>
Followup-To comp.lang.php
MIME-Version 1.0
Lines 50
NNTP-Posting-Date 05 Feb 2012 03:15:23 CET
NNTP-Posting-Host c1a0ac9e.newsspool1.arcor-online.net
X-Trace DXC=Hje^QB^lJ6f]BlmkiiU@Biic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgbD^`i3[Q<Q2nDZm8W4\YJNlb@mF9jNikdeM88iJ]<ZLbjB?nHD1FHW\f
X-Complaints-To usenet-abuse@arcor.de
Xref x330-a1.tempe.blueboxinc.net comp.lang.php:4727

Followups directed to: comp.lang.php

Show key headers only | View raw


John wrote:

> Am 05.02.2012 00:05, schrieb Thomas 'PointedEars' Lahn:
>>    $words = str_split(' ', preg_replace('/\\s+/', ' ', $text));

That is _not_ what I *recommended*.  Please learn to quote.

> I have the problem of  'filtering' a text file, exported from Excel as a
> 'Windows text file with <return>', containing <tabs> between numbers.

Sounds like a CSV file, having <HT> as field delimiter and <CR><LF> as 
record delimiter.  Right?

> 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 this is a CSV file and the fields contain a number each, not words, then 
I do not see how additional splitting at /\s+/ would help.  The fields 
should not contain white-space as they contain only one number each and are 
delimited by white-space, in particular <HT> ("\t").

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

Do you know <http://php.net/fgetcsv>?
 
>> 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.

You are welcome.  (But there should be no space before the `!' in English or 
German.)


PointedEars
-- 
    realism:    HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness:    XHTML 1.1 as application/xhtml+xml
                                                    -- Bjoern Hoehrmann

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-03 20:03 +0100
  Re: reduce all spaces to one Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-03 14:36 -0500
    Re: reduce all spaces to one crankypuss <no@email.thanks> - 2012-02-03 13:05 -0700
      Re: reduce all spaces to one Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-03 15:17 -0500
      Re: reduce all spaces to one "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-02-03 21:19 +0100
        Re: reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-03 21:59 +0100
          Re: reduce all spaces to one Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-04 15:41 +0100
            Re: reduce all spaces to one Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-04 09:57 -0500
              Re: reduce all spaces to one Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-04 16:05 +0100
              Re: reduce all spaces to one Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-04 16:21 +0100
                Re: reduce all spaces to one Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-04 16:00 -0500
              Re: reduce all spaces to one Michael Fesser <netizen@gmx.de> - 2012-02-05 21:47 +0100
                Re: reduce all spaces to one Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-05 16:12 -0500
                Re: reduce all spaces to one "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-02-05 22:23 +0100
                Re: reduce all spaces to one The Natural Philosopher <tnp@invalid.invalid> - 2012-02-05 21:37 +0000
                Re: reduce all spaces to one Michael Fesser <netizen@gmx.de> - 2012-02-05 23:34 +0100
            Re: reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-04 22:26 +0100
              Re: reduce all spaces to one Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-05 00:05 +0100
                Re: reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-05 01:39 +0100
                Re: reduce all spaces to one Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-04 20:56 -0500
                Re: reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-05 18:02 +0100
                Re: reduce all spaces to one Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-05 03:15 +0100
                Re: reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-05 18:04 +0100
                Re: reduce all spaces to one Doug Miller <doug_at_milmac_dot_com@example.com> - 2012-02-05 04:02 +0000
                Re: reduce all spaces to one Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-05 05:35 +0100
                Re: reduce all spaces to one Doug Miller <doug_at_milmac_dot_com@example.com> - 2012-02-06 01:31 +0000
                Re: reduce all spaces to one "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-02-06 09:31 +0100
                [OT]: "native" English (was: reduce all spaces to one) Gregor Kofler <usenet@gregorkofler.com> - 2012-02-05 11:03 +0100
                Re: [OT]: "native" English The Natural Philosopher <tnp@invalid.invalid> - 2012-02-05 10:11 +0000
                Re: [OT]: "native" English Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-05 14:00 +0100
                Re: [OT]: "native" English The Natural Philosopher <tnp@invalid.invalid> - 2012-02-05 13:53 +0000
                Re: reduce all spaces to one John <john_takethisoff@agdp.de> - 2012-02-05 18:05 +0100
  Re: reduce all spaces to one "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-02-03 21:30 +0100

csiph-web