Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Use of compile flags in regular expressions.

Reply
Thread Tools

Use of compile flags in regular expressions.

 
 
Steven W. Orr
Guest
Posts: n/a
 
      07-19-2012
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?
* If not, is there another way?
* 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?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Use of compile flags in regular expressions. MRAB Python 0 07-19-2012 03:15 PM
Re: Quetion about flags of socket.recv(bufsize, [flags]) Steve Holden Python 0 02-08-2009 04:09 PM
__future__ and compile: unrecognised flags Poor Yorick Python 0 12-13-2008 11:29 AM
Platform-specific compile flags in setup.py? Nikita the Spider Python 1 03-05-2007 03:14 AM
Preference: Header File OR Compile Flags? Brock C Programming 4 12-11-2003 12:52 PM



Advertisments