Re: Baby's First Regex! (Repost - Please Help)
| From: | Brian Clark | Date: | Tue, 09 Jan 2001 23:41:25 +0000 |
| Subject: | Re: Baby's First Regex! (Repost - Please Help) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33590@lists.php.net to get a copy of this message | ||
Hello Murray,
(MS == "Murray Shields") murray@mu.com.au writes:
MS> I have written my first regex's, which are simply used for
MS> validation of input into a web form. Basically, they check to see
MS> if an invalid characters are being entered, and is working
MS> perfectly. A different regex is used to different types of input.
MS> They are as follows
<snipped examples>
MS> At the moment, the error message sent to the browser is along the
MS> lines of "You have entered invalid characters. Please check and
MS> try again." However, I would rather be able to tell them WHICH
MS> characters they entered represent a problem.
You can use parentheses around items you wish to match-and-store and
refer to those items later.
There is a 3rd argument to ereg(), and that can hold your matches.
ereg (string pattern, string string [, array regs])
Look at the example on this page:
http://www.php.net/manual/html/function.ereg.html
And for a different flavor:
http://www.php.net/manual/html/function.ereg-replace.html
MS> How can I get a the list of characters tht causes one of these
MS> regex's to fail?
-Brian
--
While money can't buy happiness, it certainly
lets you choose your own form of misery.