[issue47163] "unterminated subpattern" in valid regex if re.VERBOSE is used

2022-03-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47163] "unterminated subpattern" in valid regex if re.VERBOSE is used

2022-03-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

"#" in VERBOSE mode starts a comment and skips to the end of the line. Escape 
it: "\#".

--
nosy: +serhiy.storchaka
resolution: not a bug -> 
stage: resolved -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47163] "unterminated subpattern" in valid regex if re.VERBOSE is used

2022-03-30 Thread Ned Batchelder


Ned Batchelder  added the comment:

I realized my mistake... never mind!

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47163] "unterminated subpattern" in valid regex if re.VERBOSE is used

2022-03-30 Thread Ned Batchelder


New submission from Ned Batchelder :

In this code, the same regex is compiled with and without re.VERBOSE.  Without, 
it compiles fine.  With, it fails with an "unterminated subpattern" error.

list_num_rx1 = r"""(?P\()?(\d+|#|[a-z])(?(paren)\)|\.)"""
list_num_rx2 = r"""(?x)(?P\()?(\d+|#|[a-z])(?(paren)\)|\.)"""

# This works:
re.compile(list_num_rx1)
# Either of these fails:
re.compile(list_num_rx1, flags=re.VERBOSE)
re.compile(list_num_rx2)

(What I really wanted was this, but the error happens without the multiline 
string:)

list_num_rx = r"""(?x)
(?P\()?  # maybe an opening paren
(\d+|#|[a-z])   # the number: 123, or #, or a-z
(?(paren)   # if we had an opening paren..
\)| #   then we need a closing paren
\.  #   otherwise a dot.
)
"""

--
components: Regular Expressions
messages: 416340
nosy: ezio.melotti, mrabarnett, nedbat
priority: normal
severity: normal
status: open
title: "unterminated subpattern" in valid regex if re.VERBOSE is used

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com