giraffemedia Posted August 22, 2011 Share Posted August 22, 2011 Hello, I have two functions in my document that convert anything in a string between the characters [] as a link <a href="example.com">example</a> or {} as a paragraph <p class="example">example</p> like so… Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed aliquet, ante et blandit fermentum, [www.example.com] sem elit fermentum odio, sit amet sagittis arcu libero vitae nunc. Sed sed viverra diam. Etiam tristique sagittis neque id aliquet. {Etiam quam enim, vestibulum nec hendrerit nec, faucibus ut est.} Donec vel orci eu elit pretium euismod ac vitae nisi. Praesent scelerisque aliquet nunc vel ultrices. Praesent interdum massa at dolor tempus aliquet. What I would like is a new function that wraps all other text in <p></p> tags but leaves the one's I have already processed. I want it to look like the following… <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> <p>Sed aliquet, ante et blandit fermentum, <a href="www.example.com">www.example.com</a> sem elit fermentum odio, sit amet sagittis arcu libero vitae nunc. Sed sed viverra diam. Etiam tristique sagittis neque id aliquet.</p> <p class="example">Etiam quam enim, vestibulum nec hendrerit nec, faucibus ut est.</p> <p>Donec vel orci eu elit pretium euismod ac vitae nisi. Praesent scelerisque aliquet nunc vel ultrices. Praesent interdum massa at dolor tempus aliquet.</p> Is it possible to write one function that does all of this in one? Thanks, James Quote Link to comment https://forums.phpfreaks.com/topic/245424-preg_replace-to-add-tags-to-text-not-surrounded-by-specific-charcters/ Share on other sites More sharing options...
titan21 Posted August 22, 2011 Share Posted August 22, 2011 without seeing the code - can u not run the function to generate the <p> and then immediately afterwards run the [] function? Quote Link to comment https://forums.phpfreaks.com/topic/245424-preg_replace-to-add-tags-to-text-not-surrounded-by-specific-charcters/#findComment-1260522 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.