Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25630 > unrolled thread
| Started by | MRAB <python@mrabarnett.plus.com> |
|---|---|
| First post | 2012-07-19 16:15 +0100 |
| Last post | 2012-07-19 16:15 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Use of compile flags in regular expressions. MRAB <python@mrabarnett.plus.com> - 2012-07-19 16:15 +0100
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Date | 2012-07-19 16:15 +0100 |
| Subject | Re: Use of compile flags in regular expressions. |
| Message-ID | <mailman.2305.1342710940.4697.python-list@python.org> |
On 19/07/2012 15:22, Steven W. Orr wrote: > I have a problem that I'm solving using a regex. (Yeah, I know, now I have two > problems...) ;-)> > > Anyways, the regex is about a couple of pages long and it works just peachy. > There's just one thing I'd like to do to make it more elegant. > > I need to compile the regex with MULTILINE and DOTALL. But there are a few > sections where I wish it was *not* compiled with DOTALL. For those cases, I > use (something like) > > [^\n]* > > instead of > > .* > > I see that I can use the (?MS) construct but I also see that it applies > globally and not to the subgroup that I'm using it in. > > * Is there a way to make it apply locally to a subgroup? It with the re module. > * If not, is there another way? The DOTALL . could be replaced with, say, [\d\D]. > * Also, is this an incredible stroke of genius that I came up with this idea > of applying flags to a subgroup, or have others thought of this too and found > out that it's not really a good idea? > Many other regex implementations do support scoped flags, including the one here: http://pypi.python.org/pypi/regex which is designed to be backwards-compatible with the re module.
Back to top | Article view | comp.lang.python
csiph-web