bbcode highilight

Started on the old forum in December 2010 · view the original in the archive · old links redirect here

8 replies · 698 views · started 15 years ago · 1 min read

7 participants
ionutvmi Junior · 45 posts #1

hello, I'm trying to do a bbcode that highlight the string between so i foum this. $string = preg_replace("/[code](.+?)[/code]/eiU", "highlight_string("$1", true);", $string); It works if $string in only in one line $string ="[ code] <?php echo 'do'; [/code ]"; But if i make in more lines. $string ="[ code]

<?php echo 'do'; [/code ]"; Not working Any help ?

PIMP-WAP.NET - PIMP YOUR MOBILE

MASTER-LAND.NET - WAPMASTERS LAND

something else Fellow · 2,296 posts #2

Try:

$string = preg_replace("/\[code\](.*)\[\/code\]/is", highlight_string($1), $string);
shakil420 Developer · 125 posts #3

code doesnt working @ s else bro

ionutvmi Junior · 45 posts #4

yes i forgot to reply, try this @ shakil

$string = preg_replace("/\[code\](.*) \[\/code\]/es","highlight_string('$1')", $string);

PIMP-WAP.NET - PIMP YOUR MOBILE

MASTER-LAND.NET - WAPMASTERS LAND

metulj Super moderator Principal · 1,726 posts #5

this will work

$string = preg_replace("/\[code\](.*)\[\/code\]/isUe", "'<code>\\1</code>'", $string);

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

Wapito Newbie · 8 posts #7

Yeah its working, but when i post two codes at the same time like:

first code here [ code] blah.. blah..[ /code] second code here [ code] blah.. blah..[ /code]

only the first code is highlighten..

arnage Lead · 811 posts #8

Try to add "m" multiline modifier to regex.

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close