PHP preg_match wildcard ??

Status
Not open for further replies.

adrian5750

New Member
HI Folks
I'm very much a PHP newbie here - but have managed to successfully 'adapt' some 'guestbook' code to filter out some of the inevitable pornospam....

The fragment in question is this.....

if (preg_match("/http", ($comment))) {
exit();
}

...which works fine if the spam contains http<space> - but fails to spot httpsomethingelse

Is there the equivalent of the old DOS wildcard * - so that my preg_match will pick up http-without-a-space-after-it ...?

I'm sure that there must be - but a web-trawl very quickly got me in much deeper than I wanted to be <g> - and I'm hoping that somebody out there could point me in the right direction....

(Looks like I'm going to have to learn another programming language.... I'm getting tooo old for this ! <g>)

Thanks in advance
Adrian
 

louie

New Member
try this:
if (preg_match("/http\s?/", ($comment))) {
exit();
}

the forum removes the [back-slash] \ that should be before "s"
 

adrian5750

New Member
HI Louie

Thanks for the reply.....

Actually seem to have sort of fixed it (he said confidently).

I have the same check elsewhere in the same suite of php scripts - difference being that the term in the preg_wotsit was

"/http/"

rather than what I originally had - which was

"/http"

As I say - I'm not confident enought to know 'why' this works - but it does seem to have the desired effect......

.......really don't want to properly learn all of this ..... life's too short ! <g>

Thanks
Adrian
 
Status
Not open for further replies.
Top