vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Preg_replace.. (https://vborg.vbsupport.ru/showthread.php?t=64022)

TouchingVirus 04-17-2004 10:00 PM

Preg_replace..
 
I cant understand the thing at all...

ereg_replace, preg_replace..i just dont get it..

I read the format on php.net and everything, its just all that ^# and ^|#@ things that i dont get..

Anyone care to share the light with a little tutorial?? :D

assassingod 04-17-2004 10:08 PM

Take alook at the second example at http://uk.php.net/manual/en/function.preg-replace.php

The 1st parameter is what the function will look for in the defined string, the 2nd parameter is what will be replaced if there are matches in the string, and the 3rd parameter is the string you define.

I,e
PHP Code:

<?php

    
// my string that i am making
    
$string "assassingod is the best at everything";

    
// what its looking for and if theres a match itll be replaced
    
$patterns[0] = "/best/";
    
$patterns[1] = "/at everything/";

    
// what is going to be inplace of what has been removed
    
$replacements[0] = "worst";
    
$replacements[1] = ".";

    echo 
preg_replace($patterns$replacements$string);
    
?>

The output of that will be
Quote:

assassingod is the worst .
(Of course that's a false statement;))

TouchingVirus 04-17-2004 10:41 PM

Ok, thanks for that assassingod..

What about 3 and 4 and 5..

PHP Code:

"/(<\/?)(\w+)([^>]*>)/e"
             
"'\\1'.strtoupper('\\2').'\\3'" 

Like what is all that...that is what confuses me :D

Dean C 04-18-2004 11:04 AM

Those are regular expression pattern matchers. They were taken from perl. As much as I I'd like to sit down an explain to you about them I don't know much about them myself yet ;) In fact it would take anyone some time to explain it. I suggest looking for some tutorials on 'PHP regular expressions' and reading the section in the PHP manual about them. They're quite hard to get your head around :)

TouchingVirus 04-18-2004 03:48 PM

thanks for the advice dean :)


All times are GMT. The time now is 12:30 PM.

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.01039 seconds
  • Memory Usage 1,723KB
  • 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
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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