--- Wade Smart <[EMAIL PROTECTED]> wrote:
> A piece of hardware puts out a formatted report daily that I need to
> extract the data from. There are 13 columns of information. The data in
> the columns are from 1 to 5 possibly 6 places with no 0's as place holders.
>
> What I need to do is remove all the spaces except 1 between all the
> columns.
>
> I thought about doing something like:
>
>
> do{ $pos_start = $pos_start + 1; }
> while ( !chr(32);
>
> But that doesnt work.
>
> Would someone give me a suggestion.
>
> Wade
You are probably seeking a regular expression to search for one or more spaces
and replace them with a single space. The search pattern would be something
like:
\s+
The \s includes several whitespace characters (including tabs) so you might
care to code the space specifically. Then replace it with the space character.
$input = "Text more text";
$output = preg_replace("/\s+/", " ", $input);
There is some overhead in using the regular expression engine but it is quite
flexible for this application.
James