Re: [PHP] Re: SeparatingWords
Just to make a fool of myself, I'd explode the string, parse each item and implode. I'm sure it can be done through some regexp wizardry as well - probably matching something along the lines of "(^\ [A-Z])" but I'm way too retarded regexp-wise. BTW, any good online tutorials? I read through PHP's reference docs (which are probably excellent if you already know what it's all about), but only reached a limited understanding of how to approach problems... Bogdan Dl Neil wrote: > Philip, > What about "SoftwareVersion Thingy"? > Won't that end up as "Software Version Thingy" - with two spaces before the > "T"? > Can the RegEx be 'turned off' if the u/case letter is already preceded by a > space? > (sorry, may not be Hessu's requirement = my curiosity) > Regards, > =dn > > > >>This works. >> >>$word = "SoftwareVersionThingy"; >>$word = ereg_replace("([A-Z])", " \\1", $word); >>$word = ltrim($word); >> >>-philip >> >>On Thu, 22 Aug 2002, Hessu wrote: >> >> >>>Hi, >>> >>>I have strings like FileName, SoftwareVersion etc. >>>How can I add space between words? Somehow with preg_replace perhaps? >>>First letter of each word is capitalized. >>> >>>-Hessu- >>> >>>-- >>>PHP General Mailing List (http://www.php.net/) >>>To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SeparatingWords
Yes, it would and yes you can, but I'll leave that up to you :) On Wed, 21 Aug 2002, DL Neil wrote: > Philip, > What about "SoftwareVersion Thingy"? > Won't that end up as "Software Version Thingy" - with two spaces before the > "T"? > Can the RegEx be 'turned off' if the u/case letter is already preceded by a > space? > (sorry, may not be Hessu's requirement = my curiosity) > Regards, > =dn > > > > This works. > > > > $word = "SoftwareVersionThingy"; > > $word = ereg_replace("([A-Z])", " \\1", $word); > > $word = ltrim($word); > > > > -philip > > > > On Thu, 22 Aug 2002, Hessu wrote: > > > > > Hi, > > > > > > I have strings like FileName, SoftwareVersion etc. > > > How can I add space between words? Somehow with preg_replace perhaps? > > > First letter of each word is capitalized. > > > > > > -Hessu- > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: SeparatingWords
Philip, What about "SoftwareVersion Thingy"? Won't that end up as "Software Version Thingy" - with two spaces before the "T"? Can the RegEx be 'turned off' if the u/case letter is already preceded by a space? (sorry, may not be Hessu's requirement = my curiosity) Regards, =dn > This works. > > $word = "SoftwareVersionThingy"; > $word = ereg_replace("([A-Z])", " \\1", $word); > $word = ltrim($word); > > -philip > > On Thu, 22 Aug 2002, Hessu wrote: > > > Hi, > > > > I have strings like FileName, SoftwareVersion etc. > > How can I add space between words? Somehow with preg_replace perhaps? > > First letter of each word is capitalized. > > > > -Hessu- > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php