On Dec 4, 11:35 pm, Paul McGuire [EMAIL PROTECTED] wrote:
Yowza! My eyes glaze over when I see re's like r'(?m)^(?Pdata.*?
(.*?.*?)*)(?:#.*?)?$!
yeah, I know ... :( ( I love complicated regexp ... it's like a puzzle
game for me)
from pyparsing import quotedString, Suppress, restOfLine
On Dec 5, 11:56 am, eric [EMAIL PROTECTED] wrote:
On Dec 4, 11:35 pm, Paul McGuire [EMAIL PROTECTED] wrote:
Yowza! My eyes glaze over when I see re's like r'(?m)^(?Pdata.*?
(.*?.*?)*)(?:#.*?)?$!
yeah, I know ... :( ( I love complicated regexp ... it's like a puzzle
game for me)
from
I have lines in a config file which can end with a comment (delimited
by # as in Python), but which may also contain string literals
(delimited by double quotes). A comment delimiter within a string
literal doesn't count. Is there any easy way to strip off such a
comment, or do I need to
On Dec 4, 4:50 pm, Joe Strout [EMAIL PROTECTED] wrote:
I have lines in a config file which can end with a comment (delimited
by # as in Python), but which may also contain string literals
(delimited by double quotes). A comment delimiter within a string
literal doesn't count. Is there
Joe Strout [EMAIL PROTECTED] writes:
I have lines in a config file which can end with a comment (delimited
by # as in Python), but which may also contain string literals
(delimited by double quotes). A comment delimiter within a string
literal doesn't count. Is there any easy way to strip
On Thu, 4 Dec 2008 at 08:50, Joe Strout wrote:
I have lines in a config file which can end with a comment (delimited by # as
in Python), but which may also contain string literals (delimited by double
quotes). A comment delimiter within a string literal doesn't count. Is
there any easy way
[EMAIL PROTECTED] wrote:
from shlex import split
split(this is a test #with a comment)
['this', 'is', 'a', 'test', '#with', 'a', 'comment']
split(this is a test #with a comment, comments=True)
['this', 'is', 'a', 'test']
split(this is a '#gnarlier' test #with a
On Dec 4, 5:15 pm, eric [EMAIL PROTECTED] wrote:
On Dec 4, 4:50 pm, Joe Strout [EMAIL PROTECTED] wrote:
I have lines in a config file which can end with a comment (delimited
by # as in Python), but which may also contain string literals
(delimited by double quotes). A comment
Using rsplit('#', 1) works for lines *with* comments:
'this is a test'.rsplit('#', 1)
['this is a test']
'this is a test #with a comment'.rsplit('#', 1)
['this is a test ', 'with a comment']
this is a '#gnarlier' test #with a comment.rsplit('#', 1)
[this is a '#gnarlier' test , 'with a
Yowza! My eyes glaze over when I see re's like r'(?m)^(?Pdata.*?
(.*?.*?)*)(?:#.*?)?$!
Here's a simple recognizer that reads source code and suppresses
comments. A comment will be a '#' character followed by the rest of
the line. We need the recognizer to also detect quoted strings, so
that
10 matches
Mail list logo