samedi 4 avril 2015

How do I select parts of a string with javascript and add html tag to that?

I Have a Paragraph and want to select the first line that ends with a ! or . or ? and give it a header tag.


Than at the end of the paragraph I want to select the words that start with a # and make them disappear.



<p>
Lorem ipsum!
Dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis.
#sociis #natoque #penatibus #magnis
</p>


Should be:



<p>
<h1>Lorem ipsum!</h1>
Dolor sit amet, consectetuer adipiscing elit. Aenean
commodo ligula eget dolor. Aenean massa. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus
mus. Donec quam felis.
</p>


This is what I have found so far: http://ift.tt/1CG1D93


Aucun commentaire:

Enregistrer un commentaire