Page 1 of 1

Simple Preg Match

Posted: Sat May 28, 2011 5:19 pm
by lenton
I want to create a pattern which will allow this: "What is [anything here]?"
Valid example: What is an orange?

This is the pattern I have so far but it doesn't seem to be working:
"/^what is *\?$/i"

Could you please tell me what I'm doing wrong? Cheers.

Re: Simple Preg Match

Posted: Sat May 28, 2011 10:40 pm
by Christopher
The * means any number of the previous thing, it your case it is a space character. The . will match any character, so maybe use "/^what is .*\?$/i"