Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34513
| Date | 2012-12-09 00:56 +0000 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: regex walktrough |
| References | <mailman.627.1354988907.29569.python-list@python.org> <50c39613$0$6972$e4fe514c@news2.news.xs4all.nl> <mailman.636.1355007486.29569.python-list@python.org> <50c3ce9d$0$6960$e4fe514c@news2.news.xs4all.nl> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.639.1355014609.29569.python-list@python.org> (permalink) |
On 2012-12-08 23:34, Hans Mulder wrote: > On 8/12/12 23:57:48, rh wrote: >> Not sure if the \w sequence includes the - or the . or the / >> I think it does not. > > You guessed right: > >>>> [ c for c in 'x-./y' if re.match(r'\w', c) ] > ['x', 'y'] >>>> > > So x and y match \w and -, . and / do not. > This is shorter: >>> re.findall(r'\w', 'x-./y') ['x', 'y'] But remember that r"\w" is more than just r"[A-Za-z0-9_]" (unless you're using ASCII).
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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