vb.org Archive

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

The Geek 11-13-2005 08:38 PM

RegEx Expression Trouble
 
HowdA All,

I am hoping one of your gurus can help we out with a small regex problem.

What I want to do is find all occurrences of "my test" in the following string:
PHP Code:

$text "my test<ul><li>my test</li></ul> <b>my test</b> my test <i>my test</i> <!--nope--> my test"

Easy huh? However the real catch is that I want to find ALL of them EXCEPT <!--nope--> my test

So this is what im doing now:
PHP Code:

#(\b((\s|<li>|<strong>|<b>|<i>)my test)s?\b)#im 

Which catches all of them. How can I do it so it explicity DOESNT catch the last one?

Thanks all!

Marco van Herwaarden 11-13-2005 08:42 PM

Ask your wife. :D
Sorry eyes are already giving me a hard time in keeping them open. If you would have posted this in the morning i would have given it a go.

Might want to wait for Dean to reply.

The Geek 11-13-2005 08:47 PM

Mrs Geek is too busy trying to find Regex for her new 'Get Geek to Wash Car Module 1.05'

Happily I have stuck it in a really good place where she should never find it :)

Any help when you can is appreciated

Comeon guys! Sont you want a cookie?

http://www.gift-baskets-4u.com/image...20Chips%20.jpg

AAAAAAAAAAAAAARGGGGGGGGGGGGGGGGGGGGGG I FREAKING HATE AUTOMERGE.


How the hell are you supposed to bump something with auto merge?

I need to find a way to get around this.

The Geek 11-19-2005 01:29 PM

Please, for the love of PETE.... someone throw me a bone here.

Marco van Herwaarden 11-19-2005 01:36 PM

Does the <!-- nope> also have a closing tag, or is everything after that ignored?

The Geek 11-19-2005 02:57 PM

Hey Marco,

The tag was <!--nope-->, however I THINK I have found the solution like this:

PHP Code:

#(\b((?<=\s|<li>|<strong>|<b>|<i>)(?<!nope--> )my test)s?\b)#im 

Basically, I wasnt properly doing a look ahead assertion.

Thanks for your help.

Andreas 11-19-2005 03:33 PM

Yep, look ahead is the way to go.


All times are GMT. The time now is 03:50 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.01155 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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