>>    http://docs.python.org/lib/re-syntax.html
>>
>> There are several good books and websites that will teach you the
>> basics of regexps, and a quick search will bring back a number of
>> results.
> 
> Thank alot thats the best response I have had.

Glad to help...though in a way, it's as much a Python or regexp 
question as a Django question.

> What is: one or more times "+" mean?

It looks at the "atom" (atom is the word used to describe "a 
thing"...a single character, a set of characters, or other group 
of expressions designated as a single unit) before it.  A few 
examples, as well as a counterpoint with "*" ("zero or more 
times") and the "{X}"/"{X,Y}" ("exactly X repetitions" and 
"between X and Y repetitions") notation.

An empty string would match "^a*$" because it contains "zero or 
more "a"s.

The string "foo" would match "^fooa*" because it's "foo" followed 
by zero or more "a"s.  (note that "a" is the atom because it's 
what immediately precedes the "*")

However neither the empty string nor "foo" would match if the "*" 
was now a "+" because you would need at least *one* (or more) "a"s.

The string "aaaaaaaa" would match both "a*" and "a+" because 
there are "zero or more" of the letter a.

As a more complex example, you can use something other than a 
single letter as an atom:

The pattern "^[aeiou]*$" will only match strings that are all 
vowels or are empty, while "^[^aeiou]*$" will only match strings 
that are all consonants or empty.  Changing the "*" to a "+" 
requires that there be at least one vowel/consonant for a match, 
and thus would fail to match the empty string.

Lastly, just as an example of the "{...}" repetition items, the 
pattern "^\d{4}$" would match exactly 4 digits, while 
"^\w{5,15}$" would match 5-15 "word" characters (as previously 
described as alphanumerics plus underscore).

> How would I pass the whole date like 12/25/2008, I is freaking out
> about the '/'?

You have to be careful how you pass these strings, but you could 
match such a pattern with

   "\d{1,2}/\d{1,2}/\d{4}"

which can be wrapped in a named capture:

   "(?P<start_date>\d{1,2}/\d{1,2}/\d{4})"

for a view that takes a parameter of "start_date"

Just remember that when it gets passed to your view:

   1) it's a string, not a date
   2) it's a pretty loose date pattern, so it does match 
"99/42/9876" so you'd have to try converting it to a date and 
then respond accordingly (if it's valid, then yay.  if it's 
bogus, let the user know to fix it)


I'll reassert that you would do well to read a couple 
web-tutorials or pick up a book on regular expressions.  They're 
a very powerful tool in the programmer's tool-belt.

Hope this helps,

-tim





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to