easy partial support for regexp -expanded #311
Replies: 5 comments 2 replies
-
Deleting also tabs, newlines, and other whitespace-class characters in the same pass is also a good idea. Then we can have multi-line regex's, which is occasionally useful for legibility. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback and the suggestion. I pushed something to master-next that you can try |
Beta Was this translation helpful? Give feedback.
-
Huzzah!!! I tested that. It's great!! Spaces, newlines, tabs, comments all worked the way you intended in regexp (i looked at the source). I didn't test regsub. And it's even documented! THANK YOU!!! This has pestered me for YEARS, ever since the first week i used jimsh. Along the way I also noticed in action several of the other improvements of this year. Excellent!! One question. In this part:
What case is that for? It wasn't obvious what its effect is. |
Beta Was this translation helpful? Give feedback.
-
Here are some
|
Beta Was this translation helpful? Give feedback.
-
sure, i'll look in the test suite and see if that change is practical for me... |
Beta Was this translation helpful? Give feedback.
-
<gush>
Been using jimsh every day for many years. It's clearly the ultimate evolution of Tcl. It should just be mainstreamed on tcl.tk instead of tclsh.</gush>
But, I used regexp -expanded all the time in tclsh (such as #310 (comment)).
jimsh never had it, and I can see why.
But every time I use any regexp, I have to start like this:
set re [string map {{ } {}} { ^ \s* (\S+) \s+ (\w+) \s+ (\d+ \. \d+ \. \d+ \. \d+ / \d+)+ \s* }]
That adds a LOT of braces and loss of legibility in order to write an expression that's supposed to have GREATER legibility. One step forward, two steps back.
I propose an easy solution: support
regexp -expanded
which simply deletes all the spaces, as in my example. Don't bother with the comment feature offered by the same option in tclsh. I've never needed it.That solution should run fast as well. Much faster than my example. And not add much executable size at all.
And it doesn't have to be called
-expanded
. There's an argument for avoiding that since the feature isn't identical to tclsh. So it would be fine to call it something else, like-compress
. But not having it at all is a real nuisance.If you can't make time for this, I understand. My life is crazy right now, but I might be able to make time for this small PR.
Beta Was this translation helpful? Give feedback.
All reactions