I'm working on a user registration page for a personal project (a labor of love, heh) and am having a bit of an issue with preg_replace.
Basically, I have a Stored Procedure that will first check to see if a user has already registered. Primarily it checks first and last name; if the name doesn't yet exist in the database, then it checks email address; if there is not already a record in the database with that name OR email address, it inserts the data.
As far as the name check, I am sending the first and last name TWICE - first as the user entered it, then also I want to send the first and last name but replacing any spaces, apostrophes, or hyphens with the "%" wildcard (ie, if the user enters a first name of "La-Jenna", "La Jenna", or "La'Jenna", the search string will be "La%Jenna".)
But the preg_replace is not swapping out spaces, apostrophes, or hyphens. Here is my replace code:
I'm guessing what you actually want for your regexp is:
Code:
"/[ '-]/i"
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks