On Monday, August 17, 2020 at 9:49:13 AM UTC-4, Edward K. Ream wrote:
>
> I would like a regex that finds complete and *disjoint *typescript
> multiline block comments
>
> The following does not work, because the flags do not play well together.
>
> re.compile(r'(/\*.*?\*/)(.*)', re.DOTALL | re.MULTILINE)
>
> For example, even with .*?, the pattern will match the *entire* string:
>
> /* first comment */
> body
> /* second comment */
>
> The relevant code is in the bug-1617 branch. It's not pretty.
>
> I don't know of any elegant solution. Do you?
>
s1 = '''/*comment one*/
not a comment
another non-comment line
/*comment 2*/
more non-comment text'''
bits = s1.split('/*')
pieces = [x.split('*/') for x in bits]
print(pieces)
[[''], ['comment one', '\nnot a comment\nanother non-comment line\n'],
['comment 2', '\nmore non-comment text']]
for p in pieces:
print(p[0])
comment one
comment 2
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/42af3257-595c-4c02-8599-65eb184ec238o%40googlegroups.com.