error_highlight icon indicating copy to clipboard operation
error_highlight copied to clipboard

Refactor Regex into methods

Open GabrielLidenor opened this issue 2 months ago • 2 comments

This helps the us to understand the regex and make it easier for a future refactoring when we want to move some methods out of the base.rb file

GabrielLidenor avatar Oct 29 '25 20:10 GabrielLidenor

Hi, thanks for working on this.

I suspected this might not work, and it looks like the failing CI confirms that. The special variable $~ is local to the scope where the match operation occurs. If String#match is called inside a new sub-method, $~ won't be visible or set in the original calling method.

Regarding the new comments, I personally find that for developers who are comfortable with regular expressions, seeing the Regexp components directly is more concise and easier to understand.

What I think would be very valuable, though, is adding comments about the intent. For example, a comment explaining the specific edge cases that led to the decision to skip closing parens would be extremely helpful for future maintenance. Actually, I can't recall the exact reason right off the top of my head :-)

mame avatar Oct 30 '25 02:10 mame

Perfect, I will be working on those changes you mentioned. Thanks for the fast response.

GabrielLidenor avatar Oct 31 '25 21:10 GabrielLidenor

will open a new PR when I am ready

GabrielLidenor avatar Nov 04 '25 20:11 GabrielLidenor