ssage-
>>>>>>>> From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
>>>>>>>> Sent: Tuesday, November 04, 2008 1:40 PM
>>>>>>>> To: Adam Williams
>>>>>>>> Cc: PHP General list
>>>>>>>>
On 6 Nov 2008, at 18:33, Thodoris wrote:
This :
ltrim($line, '0123456789 .');
does remove all those characters doesn't it (as the OP asked and
Richard suggested on a previous thread). Without calling it more
than once as far as I tested. That was my point on the first place
and sorry if
Thodoris wrote:
Ashley Sheridan a écrit :
Thats a lot of code when a couple of lines and a regex will do ;)
Maybe because the use of the regex is pointless here. A bazooka to
kill the fly ? :)
I couldn't agree more. Not to mention that they are probably slower.
Thodoris wrote:
Thodoris wrote:
Boyd, Todd M. wrote:
-Original Message-
From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 04, 2008 1:40 PM
To: Adam Williams
Cc: PHP General list
Subject: Re: [PHP] removing text from a string
On
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of Richard Heyes
> Sent: Thursday, November 06, 2008 10:26 AM
> To: Boyd, Todd M.
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] removing text from a string
>
> > RegEx
> RegEx Fan
Seriously...?
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> -Original Message-
> From: Jim Lucas [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 06, 2008 9:58 AM
> To: [EMAIL PROTECTED]
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] removing text from a string
>
> Thodoris wrote:
> >
> >> Ashle
Thodoris wrote:
>
>> Ashley Sheridan a écrit :
>>
>>> Thats a lot of code when a couple of lines and a regex will do ;)
>>
>> Maybe because the use of the regex is pointless here. A bazooka to
>> kill the fly ? :)
>>
>
> I couldn't agree more. Not to mention that they are probably slower.
>
>
uesday, November 04, 2008 1:40 PM
>>>>>> To: Adam Williams
>>>>>> Cc: PHP General list
>>>>>> Subject: Re: [PHP] removing text from a string
>>>>>>
>>>>>> On Tue, 2008-11-04 at 08:04 -0600, Adam Williams wrote:
&g
Ashley Sheridan a écrit :
Thats a lot of code when a couple of lines and a regex will do ;)
Maybe because the use of the regex is pointless here. A bazooka to
kill the fly ? :)
I couldn't agree more. Not to mention that they are probably slower.
PS Don't get me wrong I like perl and
Thodoris wrote:
Boyd, Todd M. wrote:
-Original Message-
From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 04, 2008 1:40 PM
To: Adam Williams
Cc: PHP General list
Subject: Re: [PHP] removing text from a string
On Tue, 2008-11-04 at 08:04 -0600, Adam
Ashley Sheridan a écrit :
Thats a lot of code when a couple of lines and a regex will do ;)
Maybe because the use of the regex is pointless here. A bazooka to
kill the fly ? :)
--
Mickaël Wolff aka Lupus Michaelis
http://lupusmic.org
--
PHP General Mailing List (http://www.php.net/)
To u
Micah Gersten a écrit :
Yep, with a regex, it's real easy (untested code):
So easy you got two bugs :
I hope you don't really do that in production code. It can be bogus
with big files.
$newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData);
Buggy regex.
And tex
On Wed, 2008-11-05 at 18:50 -0600, Micah Gersten wrote:
> > Yep, with a regex, it's real easy (untested code):
> >
> > >
> > $fileData = file_get_contents("text,txt");
> > $newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData);
> > file_put_contents("newfile.txt", $newFileData);
> >
>
> Yep, with a regex, it's real easy (untested code):
>
>
> $fileData = file_get_contents("text,txt");
> $newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData);
> file_put_contents("newfile.txt", $newFileData);
>
> ?>
>
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Develo
Ashley Sheridan wrote:
> On Wed, 2008-11-05 at 11:52 -0500, Wolf wrote:
>
>> 1. Some Text here
>> 2. Another Line of Text
>> 3. Yet another line of text
>> 340. All the way to number 340
>>
>> And I want to remove the Number, period, and blank space at the
>>
On Wed, 2008-11-05 at 11:52 -0500, Wolf wrote:
> > >>> 1. Some Text here
> > >>> 2. Another Line of Text
> > >>> 3. Yet another line of text
> > >>> 340. All the way to number 340
> > >>>
> > >>> And I want to remove the Number, period, and blank space at the
> > >> begining
> > >>> of each line.
Seems to me that this would work, assuming at least one space after the '.' in
every line:
$string = ltrim($string, "0123456789.");
if ($string[0] == ' ') $string = substr($string, 1);
But perhaps I'm missing something...
I dunno if the OP can guarantee at least one space or not.
I m
Thodoris wrote:
>
>> Boyd, Todd M. wrote:
>>
>>>> -Original Message-
>>>> From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
>>>> Sent: Tuesday, November 04, 2008 1:40 PM
>>>> To: Adam Williams
>>>> Cc: PHP Genera
> >>> 1. Some Text here
> >>> 2. Another Line of Text
> >>> 3. Yet another line of text
> >>> 340. All the way to number 340
> >>>
> >>> And I want to remove the Number, period, and blank space at the
> >> begining
> >>> of each line. How can I accomplish this?
> >>>
> >>> Opening the file to modi
Boyd, Todd M. wrote:
-Original Message-
From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 04, 2008 1:40 PM
To: Adam Williams
Cc: PHP General list
Subject: Re: [PHP] removing text from a string
On Tue, 2008-11-04 at 08:04 -0600, Adam Williams wrote:
I
Boyd, Todd M. wrote:
>> -Original Message-
>> From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, November 04, 2008 1:40 PM
>> To: Adam Williams
>> Cc: PHP General list
>> Subject: Re: [PHP] removing text from a string
>>
>>
On Tue, 2008-11-04 at 13:53 -0600, Boyd, Todd M. wrote:
> > -Original Message-
> > From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, November 04, 2008 1:40 PM
> > To: Adam Williams
> > Cc: PHP General list
> > Subject: Re: [PHP] removin
> -Original Message-
> From: Ashley Sheridan [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 04, 2008 1:40 PM
> To: Adam Williams
> Cc: PHP General list
> Subject: Re: [PHP] removing text from a string
>
> On Tue, 2008-11-04 at 08:04 -0600, Adam Williams wrote
On Tue, 2008-11-04 at 08:04 -0600, Adam Williams wrote:
> I have a file that looks like:
>
> 1. Some Text here
> 2. Another Line of Text
> 3. Yet another line of text
> 340. All the way to number 340
>
> And I want to remove the Number, period, and blank space at the begining
> of each line. Ho
> Thanks Boyd, your code did exactly what I wanted!
Y'know you could do this with ltrim()... :-)
--
Richard Heyes
HTML5 Graphing for FF, Chrome, Opera and Safari:
http://www.rgraph.org (Updated November 1st)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.p
Thanks Boyd, your code did exactly what I wanted!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
> -Original Message-
> From: Adam Williams [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 04, 2008 8:04 AM
> To: PHP General list
> Subject: [PHP] removing text from a string
>
> I have a file that looks like:
>
> 1. Some Text here
> 2. Another Line of Text
> 3. Yet another line of t
= 0))
$thedata = trim(mb_substr($thedata,
$position_of_dot,
mb_strlen($thedata, $encoding), $encoding));
}
//print the modified line and \n
}
}
@fclose($fp);
?>
[mb_strpos] http://in.php.net/manual/en/function.mb-strpos.php
[m
29 matches
Mail list logo