Jump to content

Possible to insert a space between a lowercase and capital letter?


Jeffro

Recommended Posts

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!

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. 

 

 

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;

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. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.