Solved

replace text from string but keep

Posted on 2014-03-29
1
252 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 110

Accepted Solution

by:
Ray Paseur earned 500 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

729 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