Reminder: The use of “\” as a regex escape character is causing me problems in a particular coding scenario, see here: tbray.org/ongoing/When/202x/20
-
Guillaume Rossolinireplied to Guillaume Rossolini last edited by
@timbray by the way, the article might have a typo at
suppose you wanted to match anything beginning with . in my home directory:
~~timbray/~.*In that case, the * applies the literal dot any number of times (including none), which doesn’t match your description
-
@GuillaumeRossolini Oh right, need another dot. Thks.
-
@ndw yeah, I considered that a bit in the original blog.
-
@timbray I believe you're making a mistake here, but will be happy to be proven wrong.
-
@robpike Bear in mind that this is an extremely specific narrow-focus problem: Embedding regexes in JSON wrapping in Go code. I'm not for a minute proposing changing anything about the expression of regexes in other situations.
-
@robpike Having said, that, when I get this done, you're invited to give Quamina a try in the (unlikely I suppose) event that you need to filter JSON blobs on the fly. Turns out a lot of people inside Amazon had that need, at ultra high scale.
-
@timbray Wait, from what I can tell "keep \" was the most popular option on all three previous individual polls. But it's not on this one?
-
@Merovius Well, if you read the blog, I argue that retaining "\" will lead to a very poor developer experience, particularly in the area of unit testing, and I'm a bit of a testing maniac. So, as a library author, that just doesn't seem like an acceptable choice.
-
Boyd Stephen Smith Jr.replied to Merovius last edited by
-
Tim Brayreplied to Boyd Stephen Smith Jr. last edited by
@BoydStephenSmithJr @Merovius
The problem is that this is a *developer* tool, and thus developers will want to write unit tests and then production patterns, which will involve generating JSON requests from Go, which means fighting multiple levels of escaping. Most developers are very comfortable writing regular expressions and they will be doing this in their IDE, whatever it is. So I only have to tell them one thing: Write the regex, just use ~ instead of \, and everything will work.