![]() |
Data validation syntax -- looks Greek to me
Hi, all...
This is part of an example from one of the books I am using to learn PHP. I understand the purpose, but I need help understanding the specifics of the "^([_a-z.... etc. section of the code. I've already gone to the PHP Manual and did not manage to find specific help on this. Thanks very much... Dave =============================== PHP Code:
|
It's a regular expression, and they're greek to even seasoned programmers. You can read more about them here, or check out this cheat sheet to try and learn a little about them.
Basically what a regular expression does is match patterns. Like looking for a string within a string, or a specific order of characters, numbers and symbols within a string. The one you have there is looking for an email address, Code:
$regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)-m |
As delayedinsanity pointed out, Regular-Expressions.info is a nice resource. Also the PHP Manual has a helpful Regular Expression Detail section.
|
Thank you. The repsonses were very helpful. The snippet I cited was from a larger example (in one of my books) that was meant to illustrate the passing of data to a function. But I'm going through each example and trying to learn as much as I can about each detail. Very slow going, but I suppose it is bound to start coming together at some point.
Dave |
I just ordered a new book myself, "PHP Objects, Patterns, and Practice". Gotta love Amazon, it's supposed to be a $50 book, and I got a used copy for 20 bones. I don't care if my books are new, they're gonna get sat on anyways.
Good luck with it, I'm sure it'll come together. PHP's a great language. -m |
| All times are GMT. The time now is 03:43 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0