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 actually could be shorter (just found > >out) and the code didn't work with fewer than 5 char strings. > >But now is rocks. > > Hey Børge, > > 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: > > /(\d+)(\d{2})(\d{2})$/' > to this: > /(\d*)(\d{2})(\d{2})$/' > > so it won't require any digits before the final two pairs. > > * 0 or more quantifier > + 1 or more quantifier > > http://ca.php.net/manual/en/reference.pcre.pattern.syntax.php > > Paul Cool solution, and it works. =D I do however need some chars to fill in on the finished product for the look of it all, so the 0 is needed... Witch is a bit of a shame with this cool string. -- --- Børge Kennel Arivene http://www.arivene.net --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php