views:

496

answers:

1

I don't know if this is enough data to feed off of, but I have

preg_match('/SAMPLETEXT/', $bcurl, $cookie1);

and I was wondering if I can make it

preg_match($newfunction, $bcurl, $cookie1);

but when I do, I get this error "Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in".

How can I make it check for my new function, rather than have it check just for "SAMPLETEXT".

+2  A: 

Try preg_match("/$newfunction/", $bcurl, $cookie1); so that you are providing the required delimiters (using a delimiter that isn't going to be in $newfunction).

But note that the documentation says "Do not use preg_match() if you only want to check if one string is contained in another string. Use strpos() or strstr() instead as they will be faster."

ysth
This was a pure failure. It was checking the website for $function instead of the the actual random key that $function is.
Homework
I'm using cURL.
Homework
@Joey: Did you use double quotes or single quotes?
ysth
@Joey: where $bcurl comes from is really irrelevant. Either the preg_match is going to work or it isn't. Did you use double quotes as in my example?
ysth
You are amazing, thanks! It works! I didn't use double quotes before. I scanned passed your answer, and didn't look at it clearly, thanks so much. :)
Homework
Remember that you should escape the contents of `$newfunction` with preg_quote if it can contain reserved characters for regular expressions, such as `.`, `\` or `?`.
Joey