?
Solved

replace text from string but keep

Posted on 2014-03-29
1
Medium Priority
?
254 Views
Last Modified: 2014-04-13
Im trying to create a simple 'cookbook' of code and want to create snippets of code (like experts-exchange):-
My Code

Open in new window


What my plan is to do line experts exchange and do someting like:-

[codeSnippet]My Code[/codeSnippet]

I know how to find the start, and the end, but would like to pull out the code inbetween and replace with my own details, for example:-


This is some text above
[codeSnippet language=css]My Code 1[/codeSnippet]
Between text
[codeSnippet language=html]My Code 2[/codeSnippet]
And some text at the bottom

Should look like:-

This is some text above
<div class="codeSnippet">My Code 1</div>
Between text
<div class="codeSnippet">My Code 2</div>
And some text at the bottom

Any ideas how I can pull the tag out, delete the tag and then insert it into my own code?

On an improvement I wanted to include the language tag out of the first tag so I can colour the code for a bit of ease of reading.
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 2000 total points
ID: 39963953
If you follow the BBCode rules, you may find the PHP Bulletin Board Code Extension is helpful.

For display, HTML has the <code> and <pre> tags that are usually used in web page display of computer code.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question