re.compile(r'(/\*(:?.*?)\*/)') The inner comment text must be grouped separately to be able to apply *? operator on just the inner characters. Without this grouping, *? operator applies to all matched characters to the left. Your regex would match smaller part if you have had nested comments. Like /* first comment /* blah blah */ */
Vitalije On Monday, August 17, 2020 at 3:49:13 PM UTC+2, 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? > > Edward > -- 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/0aa54cda-715a-4c60-8cf6-a36b297bba42o%40googlegroups.com.
