Re: A regex puzzle

2020-08-17 Thread Thomas Passin
Yeah, I know. I was just being a bit flip. If you need what it can do, you can hardly do without. And sometimes you can find a way to format the regex string that makes it a lot more clear. On Monday, August 17, 2020 at 12:19:13 PM UTC-4, Edward K. Ream wrote: > > > > On Mon, Aug 17, 2020 at

Re: A regex puzzle

2020-08-17 Thread Edward K. Ream
On Mon, Aug 17, 2020 at 9:53 AM vitalije wrote: re.compile(r'(/\*(:?.*?)\*/)') > Thanks for this. Apparently the second group, (.*) is causing the problem. Without this second group, the original first group works! This is good news, because the second group can easily be computed. Stay

Re: A regex puzzle

2020-08-17 Thread Edward K. Ream
On Mon, Aug 17, 2020 at 11:04 AM Thomas Passin wrote: > "When you use an regex to solve a problem, then you have another problem". > This aphorism is misleading. Believing it was one of the worst mistakes I have made in my coding career. regex's are usually the simplest way to detect patterns.

Re: A regex puzzle

2020-08-17 Thread Thomas Passin
"When you use an regex to solve a problem, then you have another problem". On Monday, August 17, 2020 at 11:35:08 AM UTC-4, vitalije wrote: > > > > On Monday, August 17, 2020 at 4:59:39 PM UTC+2, Thomas Passin wrote: >> >> Nested comments aren't allowed in js and ts, are they? >> >> > Probably

Re: A regex puzzle

2020-08-17 Thread vitalije
On Monday, August 17, 2020 at 4:59:39 PM UTC+2, Thomas Passin wrote: > > Nested comments aren't allowed in js and ts, are they? > > Probably not, but that was not my point. Looking again in the original regex it seems the first group would match any number of sequences of triplets containing

Re: A regex puzzle

2020-08-17 Thread Thomas Passin
Nested comments aren't allowed in js and ts, are they? On Monday, August 17, 2020 at 10:53:37 AM UTC-4, vitalije wrote: > > 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,

Re: A regex puzzle

2020-08-17 Thread vitalije
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.

Re: A regex puzzle

2020-08-17 Thread Thomas Passin
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: A regex puzzle

2020-08-17 Thread Edward K. Ream
On Monday, August 17, 2020 at 8:49:13 AM UTC-5, Edward K. Ream wrote: I would like a regex that finds complete and *disjoint *typescript > multiline block comments > If you are interested in this puzzle, I recommend using https://pythex.org/ to play with possible solutions. Edward -- You

Re: A regex puzzle, and icon-like pattern matching

2009-10-13 Thread Edward K. Ream
On Oct 11, 6:23 am, Edward K. Ream edream...@gmail.com wrote: I've never liked regular expressions.  Their only virtue is conciseness--otherwise, they seem way under-powered. They also execute faster than other solutions, typically. A valid observations, especially if icon-like

Re: A regex puzzle, and icon-like pattern matching

2009-10-11 Thread Edward K. Ream
On Sat, Oct 10, 2009 at 11:25 AM, Ville M. Vainio vivai...@gmail.comwrote: On Sat, Oct 10, 2009 at 6:50 PM, Edward K. Ream edream...@gmail.com wrote: I've never liked regular expressions. Their only virtue is conciseness--otherwise, they seem way under-powered. They also execute faster

Re: A regex puzzle, and icon-like pattern matching

2009-10-10 Thread Edward K. Ream
On Oct 10, 10:50 am, Edward K. Ream edream...@gmail.com wrote: As an alternative, I have been playing with a python library.http://www.wilmott.ca/python/patternmatching.html The real motivation for this was as better platform for a refactoring library. It remains to be seen whether this

Re: A regex puzzle, and icon-like pattern matching

2009-10-10 Thread Ville M. Vainio
On Sat, Oct 10, 2009 at 6:50 PM, Edward K. Ream edream...@gmail.com wrote: I've never liked regular expressions.  Their only virtue is conciseness--otherwise, they seem way under-powered. They also execute faster than other solutions, typically. Find all *words* t that are not preceded by