Micah Gersten a écrit :
Yep, with a regex, it's real easy (untested code):
So easy you got two bugs :
?php
$fileData = file_get_contents(text,txt);
I hope you don't really do that in production code. It can be bogus
with big files.
$newFileData =
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
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 ? :)
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:
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
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.
PS Don't get me
-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:
Ashley Sheridan a écrit :
Thats a lot of code when
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: [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 Fan
Seriously...?
Let's just say I
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
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.
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
text from a string
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
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 have
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
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 modify it is easy, I'm just lost at how to
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
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
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. How can I accomplish this?
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
begining
of each line.
Yep, with a regex, it's real easy (untested code):
?php
$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 Developer
On Wed, 2008-11-05 at 18:50 -0600, Micah Gersten wrote:
Yep, with a regex, it's real easy (untested code):
?php
$fileData = file_get_contents(text,txt);
$newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData);
file_put_contents(newfile.txt, $newFileData);
?
Thank
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. How can I accomplish this?
Opening the file to modify it is easy, I'm
?php
$filename = .htaccess;
$fp =@ fopen($filename, r) or die (Couldn't open $filename);
// ENTER ENCODING HERE ..
$encoding = 'UTF-8';
if ($fp)
{
while (!feof($fp))
{
$thedata =@ fgets($fp);
// if every number is defonoodle separated by a dot ..
-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 text
340
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
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:
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. How can I
-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 have a file that looks like
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] removing text from a string
On Tue, 2008-11-04
30 matches
Mail list logo