Re: [PHP] removing text from a string

2008-11-06 Thread Jim Lucas
ssage- >>>>>>>> From: Ashley Sheridan [mailto:[EMAIL PROTECTED] >>>>>>>> Sent: Tuesday, November 04, 2008 1:40 PM >>>>>>>> To: Adam Williams >>>>>>>> Cc: PHP General list >>>>>>>>

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

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

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

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

Re: [PHP] removing text from a string

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

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

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

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): > > > > > > > $fileData = file_get_contents("text,txt"); > > $newFileData = preg_replace('/^\d+?\.\s?(.*$)/m','/$1/', $fileData); > > file_put_contents("newfile.txt", $newFileData); > > >

Re: [PHP] removing text from a string

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

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

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.

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 m

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 Genera

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 modi

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

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] removin

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

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

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: http://www.p

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

Re: [PHP] removing text from a string

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