vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Trying to do replacements (https://vborg.vbsupport.ru/showthread.php?t=60846)

NTLDR 01-28-2004 02:02 PM

I only know abit about it, regular expressions aren't my strong point.

@dontpanic: tofind is the search code, like survivor and replacement is the code to replace it with, I just used those as they were shorter. The ^ before the bracket should negate whats in it so if it matches the first part, but not the second then it does the replacement. At least thats how you want it too work.

dontpanic 01-28-2004 02:03 PM

Right. Now down to business. I will see what I can come up with given this great start! :)

dontpanic 01-28-2004 02:14 PM

Quote:

Originally Posted by NTLDR
Its posible to tell it to look for one thing but not another, its allong the lines of:

PHP Code:

$var preg_replace('/(tofind)^(<a href="\S">tofind</a>)/i''replacement'$var); 

Now I'm certain the above, won't work , however its along those lines ;)

NTLDR, this may be close, but PHP is seeing the
Code:

</a>
as an unknown "a" modifier.

NTLDR 01-28-2004 02:18 PM

PHP Code:

$var preg_replace('/(tofind)^(<a href="\S">tofind<\/a>)/i''replacement'$var); 

Whoops, forgot the \ before the \/a that will solve that error :)

dontpanic 01-28-2004 02:24 PM

I figured that. :)

Anyhow, I have inserted my information into the code as seen:
Code:

$post['message'] = preg_replace('/(70-292)^(<a href="\S">70-292<\/a>)/i', '<a href="http://www.mcseworld.com/a/1932266569/" target="_blank">\\1</a>', $post['message']);
This works great in the fact that it causes no errors. This does not work great in the fact that it doesn't replace anything. :ermm: Now we know why these regex's are such a pain in the butt!

I'll get back on this shortly. Gotta go do some paying work now.


All times are GMT. The time now is 01:27 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.01094 seconds
  • Memory Usage 1,727KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete