Re: [PHP] removing text from a string

2008-11-06 Thread Lupus Michaelis
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 =

Re: [PHP] removing text from a string

2008-11-06 Thread Lupus Michaelis
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

Re: [PHP] removing text from a string

2008-11-06 Thread Thodoris
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

Re: [PHP] removing text from a string

2008-11-06 Thread Thodoris
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

Re: [PHP] removing text from a string

2008-11-06 Thread Jim Lucas
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

Re: [PHP] removing text from a string

2008-11-06 Thread Jim Lucas
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

RE: [PHP] removing text from a string

2008-11-06 Thread Boyd, Todd M.
-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

Re: [PHP] removing text from a string

2008-11-06 Thread Richard Heyes
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

RE: [PHP] removing text from a string

2008-11-06 Thread Boyd, Todd M.
-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

Re: [PHP] removing text from a string

2008-11-06 Thread Thodoris
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

Re: [PHP] removing text from a string

2008-11-06 Thread Thodoris
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.

Re: [PHP] removing text from a string

2008-11-06 Thread Stut
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

Re: [PHP] removing text from a string

2008-11-06 Thread Jim Lucas
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

Re: [PHP] removing text from a string

2008-11-05 Thread Jim Lucas
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

Re: [PHP] removing text from a string

2008-11-05 Thread Thodoris
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

Re: [PHP] removing text from a string

2008-11-05 Thread Wolf
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

Re: [PHP] removing text from a string

2008-11-05 Thread Jim Lucas
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

Re: [PHP] removing text from a string

2008-11-05 Thread ceo
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

Re: [PHP] removing text from a string

2008-11-05 Thread Ashley Sheridan
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?

Re: [PHP] removing text from a string

2008-11-05 Thread Micah Gersten
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.

Re: [PHP] removing text from a string

2008-11-05 Thread Micah Gersten
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

Re: [PHP] removing text from a string

2008-11-05 Thread Ashley Sheridan
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

[PHP] removing text from a string

2008-11-04 Thread Adam Williams
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

Re: [PHP] removing text from a string

2008-11-04 Thread Yeti
?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 ..

RE: [PHP] removing text from a string

2008-11-04 Thread Boyd, Todd M.
-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

Re: [PHP] removing text from a string

2008-11-04 Thread Adam Williams
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

Re: [PHP] removing text from a string

2008-11-04 Thread Richard Heyes
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:

Re: [PHP] removing text from a string

2008-11-04 Thread Ashley Sheridan
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

RE: [PHP] removing text from a string

2008-11-04 Thread Boyd, Todd M.
-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

RE: [PHP] removing text from a string

2008-11-04 Thread Ashley Sheridan
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