Jeffro Posted April 25, 2011 Share Posted April 25, 2011 okay so this is a pretty weird one but if it's possible it would be a much easier solution that the road I'll have to take. Is it possible to code for.. $description = insert a space between a lowercase and uppercase letter is found together and not currently having a space.. within the first 50 letters of the description. if (substr($description,0,50) ?..... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/234637-possible-to-insert-a-space-between-a-lowercase-and-capital-letter/ Share on other sites More sharing options...
wildteen88 Posted April 25, 2011 Share Posted April 25, 2011 Could you provide an example. Not quite following your there. Why the need to add a space between a lowercase letter and uppercase letter? Quote Link to comment https://forums.phpfreaks.com/topic/234637-possible-to-insert-a-space-between-a-lowercase-and-capital-letter/#findComment-1205817 Share on other sites More sharing options...
spiderwell Posted April 25, 2011 Share Posted April 25, 2011 some sort of regular expression should do it, but I'm no good at those, someone will be along soon how is good at them Quote Link to comment https://forums.phpfreaks.com/topic/234637-possible-to-insert-a-space-between-a-lowercase-and-capital-letter/#findComment-1205820 Share on other sites More sharing options...
Jeffro Posted April 25, 2011 Author Share Posted April 25, 2011 Could you provide an example. Not quite following your there. Why the need to add a space between a lowercase letter and uppercase letter? FoxNewsToday in sports, we have.. TheHeraldThe weather today... etc... I have parsed an rss feed and the start of every feed looks like this. Everything else works perfect and there's just this one little flaw so I thought I'd ask about this solution first. Quote Link to comment https://forums.phpfreaks.com/topic/234637-possible-to-insert-a-space-between-a-lowercase-and-capital-letter/#findComment-1205843 Share on other sites More sharing options...
wildteen88 Posted April 25, 2011 Share Posted April 25, 2011 Does it display like that in the actual rss feed? If it doesn't then maybe you did something when parsing the rss feeds in your code. But anyway you can use regex. Something like this $str = 'ThisIsMyTestString'; $str = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str); echo $str; Quote Link to comment https://forums.phpfreaks.com/topic/234637-possible-to-insert-a-space-between-a-lowercase-and-capital-letter/#findComment-1205866 Share on other sites More sharing options...
Jeffro Posted April 25, 2011 Author Share Posted April 25, 2011 Does it display like that in the actual rss feed? If it doesn't then maybe you did something when parsing the rss feeds in your code. But anyway you can use regex. Something like this $str = 'ThisIsMyTestString'; $str = preg_replace('/([a-z])([A-Z])/', '$1 $2', $str); echo $str; That actually worked pretty nicely as a solution. Thank you! It doesn't display that in the RSS feed but I'm grabbing a yahoo pipes rss feed and I've never seen so much garbage on output.. and when I try to tell it where to start and end the "grab", it's just being very uncooperative. I'm sure I'm doing something wrong, but I'm too new to php to figure it out just yet. Since this was my only issue, I just figured solving it would be easier for now. Thanks again! I'm now reading up on regex and learning some more. Quote Link to comment https://forums.phpfreaks.com/topic/234637-possible-to-insert-a-space-between-a-lowercase-and-capital-letter/#findComment-1205930 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.