View Full Version : Filtering a string
MrEyes
02-02-2009, 12:42 PM
Lets say I have the following string:
this is some text
this is a wibble of random length
this is some more text
I need to filter out everything between, and including, and . So I would end up with the following:
this is some text
this is some more text
Does anybody know how to do that?
punchbowl
02-02-2009, 01:15 PM
function stripos($haystack, $needle, $offset=0) {
return strpos(strtoupper($haystack), strtoupper($needle), $offset);
}
That will get the position of a string in another string. After that use substr
MrEyes
02-02-2009, 01:49 PM
That will get the position of a string in another string. After that use substr
duh!! Wood for the trees and all that :)
Anyway, that works... However
I am currently working on something that will add quote functionality into vBulletin social group discussions (why this wasn't added is a mystery to me). The reason for the question is that I need to strip out quotes within the quoted post. This is something that occurs when a forum post is quoted so I am guessing that this filtering functionality already exists somewhere in the VB framework, but I will be damned if I can find it.
Does anybody know where it might be, as using the substr etc complicates things as the code will have to cater for all imaginable scenarios.
punchbowl
02-02-2009, 01:51 PM
look for the functions in postreply.php or whatever it's called? I don't know specifically
Dismounted
02-03-2009, 04:32 AM
strip_bbcode()
strip_quotes()
I think you're looking for those.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.