Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34497

regex walktrough

From rh <richard_hubbe11@lavabit.com>
Subject regex walktrough
Date 2012-12-08 09:48 -0800
Newsgroups comp.lang.python
Message-ID <mailman.627.1354988907.29569.python-list@python.org> (permalink)

Show all headers | View raw


 Look through some code I found this and wondered about what it does:
^(?P<salsipuedes>[0-9A-Za-z-_.//]+)$

Here's my walk through:

1) ^ match at start of string
2) ?P<salsipuedes> if a match is found it will be accessible in a variable
salsipuedes
3) [0-9A-Za-z-_.//] this is the one that looks wrong to me, see below
4) + one or more from the preceeding char class
5) () the grouping we want returned (see #2)
6) $ end of the string to match against but before any newline


more on #3
the z-_ part looks wrong and seems that the - should be at the start
of the char set otherwise we get another range z-_ or does the a-z
preceeding the z-_ negate the z-_ from becoming a range?  The "."
might be ok inside a char set. The two slashes look wrong but maybe
it has some special meaning in some case? I think only one slash is
needed.

I've looked at pydoc re, but it's cursory.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

regex walktrough rh <richard_hubbe11@lavabit.com> - 2012-12-08 09:48 -0800
  Re: regex walktrough Hans Mulder <hansmu@xs4all.nl> - 2012-12-08 20:33 +0100
    Re: regex walktrough rh <richard_hubbe11@lavabit.com> - 2012-12-08 14:57 -0800
      Re: regex walktrough Hans Mulder <hansmu@xs4all.nl> - 2012-12-09 00:34 +0100
        Re: regex walktrough MRAB <python@mrabarnett.plus.com> - 2012-12-09 00:56 +0000

csiph-web