PHP Programmer Needs Help with String Parsing - 150 NP$ Reward

NamecheapNamecheap
Watch

user-7256

VIP Member
Impact
111
Hi,

I don't usually start topics in this board, but I really need some assistance.

I'm working on what I hope will be a popular site and there's just 1 major obstacle keeping me from launching it, and that is this:

I am writing a simple CMS to maintain the site. In the admin panel, you can add a tutorial for others to see. The problem is when code gets embedded, it needs to be highlighted.

I've installed GeSHi which highlights it (Mambo and Wordpress use GeSHi!), and tested it:
http://www.GoTutorials.com/admin/test.php

As you can see, it works fine. Documentation here: http://qbnz.com/highlighter/geshi-doc.html

Now, I need to get it to highlight all the code between [language_name] and [/language_name] tags. ALL of them in the string.

This alone is not too difficult (even though I can't get it anyway)... but the catch:

NUMEROUS languages can go inside the brackets [ and ]. The list follows:

*Actionscript
*ADA
*Apache Log
*AppleScript
*ASM
*ASP
*Bash
*C
*C for Macs
*C#
*C++
*CAD DCL
*CadLisp
*CSS
*Delphi
*DIV
*DOS
*Eiffel
*FreeBasic
*GML
*HTML
*Inno
*Java
*Javascript
*Lisp
*Lua
*Microprocessor ASM
*NSIS
*Objective C
*OpenOffice BASIC
*Oracle 8 SQL
*Pascal
*Perl
*PHP
*Python
*Q(uick)BASIC
*SDLBasic
*Smarty
*SQL
*VB.NET
*Visual BASIC
*Visual Fox Pro
*XML


So, i need it to find the text between [ and ] and set that as the $language variable (code below). And, if it's not supported, give an error message.

The code has been uploaded and highlighted by geshi:

CODE: http://www.gotutorials.com/code.php
WHAT I HAVE NOW: http://www.gotutorials.com/admin/addtut.php

I WILL GIVE 150 NP$ FOR THE PERSON WHO MAKES THIS WORK! Right now it only does lower-case php tags... :(

Not sure what I want still? It's like this forum: You type [ php ] and [ /php ], and everything between it is highlighted in PHP. Same for [ html ] and [ /html ].

Case-INsensitivity would be wonderful also :)

Good luck,
-Matt
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
this is the regex i use for php (i'm working on a bigger system).
anyway, you might be able to adapt it.
PHP:
$pattern = "/(\[php\])(.*)(\[\/php\])/i";
preg_match($pattern, $string, $match);
highlight_string($match[2]);
 
0
•••
Hmm... that's useful, the problem is that GeSHi uses classes, and highlights the code via a class member...
 
0
•••
I Have Found Another Way To Do This. Thanks Anyway.
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back