-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected back reference scope #1057
Comments
@timhodson sorry for the very long delay. After some head-scratching I realized the issue was "obvious in hindsight" 😬 Some things:
The problem is the any part when I said "after the So, alas. I don't know a way to automatedly change this without breaking the semantics of One thing I can offer is issue #1401 and PR #1451. The good news is you can do
in between the The other thing I have to offer is the new |
@timhodson I will close this issue but please let me know if we need any more action taken & I'll happily re-open it. |
Unexpected back reference scope
Given a CSV file like this.
This miller command:
Gives:
The back reference of the original regex comparison operator remains set and is very likely to confuse anyone who is doing a number of transformations of a string.
This is a noddy example for demo purposes. My use case was splitting a URL apart, doing various regex pattern match substitutions on the parts of the URL before putting it back together again.
My solution was to split out the second substitution into a separate put statement, but this is less intuitive than having all transformations within a block as it meant repeating some tests to see if I needed to do the transformation and then pick up where I left off.
The above gives the expected:
I don't know if this is a bug or intentional, but I wasn't expecting it and it took me several days of hair pulling to spot what was happening!
So if nothing else this may help someone else resolve unexpected side effects of using back references with the
=~
operator.The text was updated successfully, but these errors were encountered: