I am using this example:
New Zealand cyclist Jack Bauer didn't know it during the Olympic road race, but there was a scantily-clad Kiwi 'snow angel' above him. http://www.stuff.co.nz/sport/olympics/7374497/Near-naked-snow-angel-over-cycle-road-race
I want to add a <br /> tag after the full stop but not in HTTP link. Just at the end of the sentence.
Currently I am using :
$full_story = $read_story->[0]{story_text};
$full_story =~ s/(\D)\.(\D)/<br \/><br \/>/i;
Using this code it adds the <br /> but the m from him is being removed.
Final Result:
New Zealand cyclist Jack Bauer didn't know it during the Olympic road race, but there was a scantily-clad Kiwi 'snow angel' above him.
http://www.stuff.co.nz/sport/olympics/7374497/Near-naked-snow-angel-over-cycle-road-race
What am I doing wrong?
You could do a search and replace ‘s///’
given the string:
you could do:
the ‘s’ means you’re doing a search and replace.
Between the first two ‘/ /’ is the one you’re searching for. In this case it’s a dot (.) but you have to escape it with \ since dot in regex is a wild card.
Between the next ‘/ /’ is the text you’re trying to replace. In this case it’s
<br />. again you have to escape ‘/’ in here since it’s a special character.Lastly, the ‘g’ flag at the end means your searching and replacing in the whole string.
So in my example the output would be:
Since you don’t want to replace the dots in the string, you could simple separate them in different variables so that it will be easier to manipulate.