Re: [PHP] Splitting a string ...

2010-03-15 Thread shiplu
Here is the regex for you. $company_domain = '\w+'; // replace with your own company domain pattern. $user_name = '\w+'; // replace with your own username pattern $email_domain = '\w+\.\w{2,4}'; // google for standard domain name regex pattern and replace it. $regexp = "~({$company_domain}[

Re: [PHP] Splitting a string ...

2010-03-14 Thread Jochem Maas
Op 3/15/10 1:54 AM, Ashley M. Kirchner schreef: > I'm not a regexp person (wish I was though), and I'm hoping someone can give > me a hand here. Consider the following strings: > > > > - domain\usern...@example.org > > - domain\username > > - the same as above but

Re: [PHP] splitting a string

2010-01-05 Thread Ashley Sheridan
On Tue, 2010-01-05 at 14:26 +0100, Daniel Egeberg wrote: > On Tue, Jan 5, 2010 at 14:13, Ashley Sheridan > wrote: > > (untested - I always forget the order of the params!) > > As a general rule, string functions are always haystack-needle and > array functions are always needle-haystack. I can'

Re: [PHP] splitting a string

2010-01-05 Thread Daniel Egeberg
On Tue, Jan 5, 2010 at 14:13, Ashley Sheridan wrote: > (untested - I always forget the order of the params!) As a general rule, string functions are always haystack-needle and array functions are always needle-haystack. I can't think of any exceptions to that rule. -- Daniel Egeberg -- PHP Ge

Re: [PHP] splitting a string

2010-01-05 Thread Ashley Sheridan
On Tue, 2010-01-05 at 12:39 +, Ingleby, Les wrote: > Hi all, first time I have posted here so please be nice. > > I am using PEAR HTTP_Upload to handle multiple file uploads. What I need to > do is to take the file name which is output using the getProp() function and > then remove the file

Re: [PHP] splitting a string

2010-01-05 Thread Daniel Egeberg
On Tue, Jan 5, 2010 at 13:39, Ingleby, Les wrote: > Hi all, first time I have posted here so please be nice. > > I am using PEAR HTTP_Upload to handle multiple file uploads. What I need to > do is to take the file name which is output using the getProp() function and > then remove the file exten

Re: [PHP] Splitting a string

2006-11-16 Thread Paul Novitski
On Thursday 16 November 2006 01:38, Paul Novitski wrote: > If you need to left-pad with zeroes, PHP comes to the rescue: > http://php.net/str_pad > > However, if you're using the regular expression > method then you might not need to pad the > number. You can change the pattern from this: > >

Re: [PHP] Splitting a string

2006-11-16 Thread Børge Holen
On Thursday 16 November 2006 01:38, Paul Novitski wrote: > At 11/15/2006 02:06 PM, Børge Holen wrote: > >Oh this was good. > >I added a while loop to insert extra strings "0" > >in front of the number to add > >if the string is less than 5 chars short. > > > >I forgot to mentinon that the string ac

Re: [PHP] Splitting a string

2006-11-16 Thread Børge Holen
On Thursday 16 November 2006 01:12, Robert Cummings wrote: > On Thu, 2006-11-16 at 10:47 +1100, Chris wrote: > > Børge Holen wrote: > > > Oh this was good. > > > I added a while loop to insert extra strings "0" in front of the number > > > to add if the string is less than 5 chars short. > > > > sp

Re: [PHP] Splitting a string

2006-11-15 Thread Paul Novitski
At 11/15/2006 02:06 PM, Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings "0" in front of the number to add if the string is less than 5 chars short. I forgot to mentinon that the string actually could be shorter (just found out) and the code didn't work with fe

Re: [PHP] Splitting a string

2006-11-15 Thread Chris
Robert Cummings wrote: On Thu, 2006-11-16 at 10:47 +1100, Chris wrote: Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings "0" in front of the number to add if the string is less than 5 chars short. sprintf is your friend here, no need to use a loop. sprintf('%0

Re: [PHP] Splitting a string

2006-11-15 Thread Robert Cummings
On Thu, 2006-11-16 at 10:47 +1100, Chris wrote: > Børge Holen wrote: > > Oh this was good. > > I added a while loop to insert extra strings "0" in front of the number to > > add > > if the string is less than 5 chars short. > > sprintf is your friend here, no need to use a loop. > > sprintf('%0

Re: [PHP] Splitting a string

2006-11-15 Thread Chris
Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings "0" in front of the number to add if the string is less than 5 chars short. sprintf is your friend here, no need to use a loop. sprintf('%05d', '1234'); -- Postgresql & php tutorials http://www.designmagick.com

Re: [PHP] Splitting a string

2006-11-15 Thread Børge Holen
Oh this was good. I added a while loop to insert extra strings "0" in front of the number to add if the string is less than 5 chars short. I forgot to mentinon that the string actually could be shorter (just found out) and the code didn't work with fewer than 5 char strings. But now is rocks.

Re: [PHP] Splitting a string

2006-11-15 Thread Børge Holen
On Wednesday 15 November 2006 12:42, Robin Vickery wrote: > On 15/11/06, Aaron Koning <[EMAIL PROTECTED]> wrote: > > Assuming var1 and var2 only ever use the last four numbers (untested): > > > > $length = strlen($number); // get string length > > $var1 = substr($number,0,$length-4); // get number

Re: [PHP] Splitting a string

2006-11-15 Thread Børge Holen
On Wednesday 15 November 2006 06:24, you wrote: > At 11/14/2006 03:17 PM, Børge Holen wrote: > >$number = 123456789 > > > >should print as following: > >var1: 12345 (and it is this lengt witch varies) > >var2: 67 > >var3: 89. > > You can also do this with a regular expression: > > $iNumber = '123

Re: [PHP] Splitting a string

2006-11-15 Thread Robin Vickery
On 15/11/06, Aaron Koning <[EMAIL PROTECTED]> wrote: Assuming var1 and var2 only ever use the last four numbers (untested): $length = strlen($number); // get string length $var1 = substr($number,0,$length-4); // get number until only 4 numbers are left $var2 = substr($number,$length-4,2); // get

Re: [PHP] Splitting a string

2006-11-14 Thread Paul Novitski
At 11/14/2006 03:17 PM, Børge Holen wrote: $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. You can also do this with a regular expression: $iNumber = '123456789'; $sPattern = '/(\d+)(\d{2})(\d{2})$/'; preg_match($sPattern, $

Re: [PHP] Splitting a string

2006-11-14 Thread Aaron Koning
Assuming var1 and var2 only ever use the last four numbers (untested): $length = strlen($number); // get string length $var1 = substr($number,0,$length-4); // get number until only 4 numbers are left $var2 = substr($number,$length-4,2); // get 3rd and 4th last numbers. $var3 = substr($number,$len

Re: [PHP] Splitting a string

2006-11-14 Thread Darrell Brogdon
What's the code? -D On Nov 14, 2006, at 4:17 PM, Børge Holen wrote: This numer has dynamic lenght, witch is the root of my problems. $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. I've been using substr with negative numb

Re: [PHP] Splitting a string by the number of characters in the string?

2004-07-30 Thread Jason Wong
On Friday 30 July 2004 15:44, Brent Clements wrote: > In PHP 5 there is a awesome function called str_split, is there an > equivalent in PHP 4.x? > > I need to do the following: > > Split a 60 character string into 3 20 character array chunks. > > using str_split I could easily do it, but how do I

Re: [PHP] Splitting a string by the number of characters in the string?

2004-07-30 Thread Justin Patrin
On Fri, 30 Jul 2004 02:44:19 -0500, Brent Clements <[EMAIL PROTECTED]> wrote: > In PHP 5 there is a awesome function called str_split, is there an equivalent in PHP > 4.x? > > I need to do the following: > > Split a 60 character string into 3 20 character array chunks. > > using str_split I cou

Re: [PHP] Splitting a string

2003-03-13 Thread - Edwin
Hi, David Rice <[EMAIL PROTECTED]> wrote: > > $str = "S12345"; > $str1 = ltrim($str,"S"); Good idea but you'd have problem if you have $str = "SS12345"; and you only want to get rid of the first one... - E __ Do You Yahoo!? Yahoo! BB is Broadba

RE: [PHP] Splitting a string

2003-03-13 Thread Crane, Christopher
-4379 -Original Message- From: - Edwin [mailto:[EMAIL PROTECTED] Sent: Thursday, March 13, 2003 9:30 AM To: Christopher J. Crane; [EMAIL PROTECTED] Subject: Re: [PHP] Splitting a string Hi, "Christopher J. Crane" <[EMAIL PROTECTED]> wrote: [snip] > If that number

Re: [PHP] Splitting a string

2003-03-13 Thread David Rice
Then split the variable where there is a "S". The problem showed up when there is another "S" in the field. I only want to split the first "S" at the beginning of the field. Isn't there an additional value to add to the split $line = 'S12345'; if ($line[0] == 'S') { /* do stuff */ } $st

Re: [PHP] Splitting a string

2003-03-13 Thread David Otton
On Thu, 13 Mar 2003 09:13:35 -0500, you wrote: >Then split the variable where there is a "S". The problem showed up when >there is another "S" in the field. I only want to split the first "S" at the >beginning of the field. Isn't there an additional value to add to the split $line = 'S12345'; if

Re: [PHP] Splitting a string

2003-03-13 Thread - Edwin
Hi, "Christopher J. Crane" <[EMAIL PROTECTED]> wrote: [snip] > If that number start with a "S", I want to strip it off. [/snip] Why don't you just check whether the first character is an "S" then return only the rest of the string if it is? Like: Of course, there could be some other way...

Re: [PHP] Splitting a string first by quotes then spaces

2001-07-09 Thread rm
Try this: first test to see if the query contain quotes, if it does, go to a seperate routine that splits the string into an array, first however, you must make sure there is a space before the query and one after the query ( you add these) *then* split the string into an array, explode on the qu