vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   preg_replace (https://vborg.vbsupport.ru/showthread.php?t=71355)

AN-net 11-04-2004 05:07 PM

preg_replace
 
well i heard preg_replace is a very hard thing in php but i thought i would give a swing at it, i did with a simple phrase already and it worked great but i cant get this one to work with variables and what nots..

heres my error:
Quote:

Originally Posted by server
Warning: Compilation failed: missing terminating ] for character class at offset 21 in /home2/animati/public_html/dev/testphp.php on line 24

my php
PHP Code:

$string"[bold]black[/bold]";
$pattern"#/[bold\](.*)\[/bold\]#esiU";
$replace"<b>$1</b>";
echo 
preg_replace($pattern$replace$string); 


Xenon 11-04-2004 05:49 PM

the [ is a special char in regular expressions, so you have to escape it if you want it to be the actual character:

PHP Code:

$pattern"#\[bold\](.*)\[/bold\]#esiU"

i assume you meant to use the backslash but used a normal slash instead ;)

AN-net 11-04-2004 06:00 PM

more errors, yeah!!!>_<

Quote:

Originally Posted by server of evil!!!
Parse error: parse error, unexpected '<' in /home2/animati/public_html/dev/testphp.php(24) : regexp code on line 1

Fatal error: Failed evaluating code: black in /home2/animati/public_html/dev/testphp.php on line 24


Xenon 11-04-2004 06:12 PM

remove the 'e' from 'esiU'

you'r not executing a callback function are you? ^^

AN-net 11-04-2004 06:17 PM

i just copied that from functions_bbcodeparse.php lol! so what does that exactly do? #siU?

i tried understanding the way php.net explains it but im just confused>_<

Xenon 11-04-2004 06:20 PM

i -> ignore cases
e -> execute a callback function (like vb does if there is a handle_bbcode()..)
s -> means a dot can be every character
not really sure about the U, i never used it right now ^^


All times are GMT. The time now is 04:11 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01158 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete