Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment regex fails with strings containing a # character #157

Open
xardnaxelax opened this issue Aug 16, 2017 · 2 comments
Open

Comment regex fails with strings containing a # character #157

xardnaxelax opened this issue Aug 16, 2017 · 2 comments
Labels

Comments

@xardnaxelax
Copy link

config.ini

[foo]
bar = ['lala', 'lele', 'here comes the # but this is not a comment']

Example:
mat = self._nolistvalue.match(value)
results in the following matching groups:

0: ['lala', 'lele', 'here comes the 
1:  but this is not a comment']

Replacing
(?:[^'"\#].*?)| # unquoted
with
(?:[^'"\#].*)| # unquoted
resolves the problem BUT leads to not correctly regexing real comments.

No idea how to easily fix that without rewriting the whole regex.

@jhermann
Copy link
Collaborator

Well, possibly re is just the wrong solution here, shlex might be a better way to (pre-)process this.

@robdennis
Copy link
Member

I agree that re here seems brittle and I think someone should probably do something after 5.1.0 is shipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants