On 05.01.2013 03:11, someone wrote:
On 01/03/2013 12:27 PM, Chris Angelico wrote:
On Thu, Jan 3, 2013 at 10:19 PM, someone <newsbo...@gmail.com> wrote:
Doesn't this "[ ... ]" mean something optional?

What does {2,30}$ mean?

I think $ means that the {2,30} is something in the end of the
sentence...

You can find regular expression primers all over the internet, but to
answer these specific questions: [...] means any of the characters in
the range; the $ means "end of string"; and {2,30} means at least two,
and at most thirty, of the preceding character. So you have to have
one from the first group, then 2-30 from the second, for a total of
3-31 characters in your names.

Got it, thanks!



Just following the discussion which is very interesting, even so when not working with OpenGL (which looks like a nightmare with that naming space) :)

But about the regular expressions (a bit deeper look into that):
Like said of Chris:

[a-z]
defines a "catching group", in this case all ascii lowercase letters ranging from "a" to "z". If noting else is provided, the rule matches one letter if there is no range defined by something like:
{} -> Target a range of a match/hit

There are also a
? -> Lazy match
* -> Gready match

[A-Z][0-9]{1,3} means translated:
Look for any uppercase letter in ascii(!) (not "öäü" or similiar) ranging from "A" to "Z".

Now look for any digit (2nd catching group) with the addition to satisfy the rule ONLY if there are at least 1 to 3 digits found. Note: If there are 4 or more digits - the catching rule is still satisfied and will provide a match/hit.

If there is a follow up group, the next evaluation is gone through if present and so forth. If the expression is satisfied, the match is returned.

The lazy "?" and greedy "*" matches try to satisfy, as the naming implies, to match as less or as much of what you have asked for.

For example the regular expression is valid:
0* -> Look for a zero, and be greedy as of how many zeros you want match which might follow.

Regular expressions don't have to include catching groups in order to work.

But when you use them yourself somehow, its quite simple I think.
I guess you are anyhow busy mangling with pyLint, PEP-Standards and pyOpenGL - so good luck with that :)

Jan Riechers

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to