<ruby[bot]>
henk: # => too short escape sequence: /\((?x-mi:0 ...check link for more (https://carc.in/#/r/ebth)
<henk>
leftylink: yeah, I got that, but I fail to properly understand the argument to delete(), it seems. \\\Az is one escaped backslash, one escaped 'A' and a 'z', right? why is the A escaped but not the z?
<henk>
'\\\A\z' seems to make sense. '\\Az' is one escaped backslash, and the plain letters 'A' and 'z'. I’d expect that to work as well but it doesn’t and I don’t understand why …
<leftylink>
> Uses the same rules for building the set of characters as String#count.
<henk>
huh, ok, I was reading 3.2.0 docs which don’t mention the count thing … but I’m actually using 2.7.0
<henk>
in any case: the count docs don’t yet make it clearer to me. since ruby[bot] is using 3.0 and behaves as my 2.7, I don’t think reading 2.7 docs will help either
<weaksauc_>
if you do Az\\ it will remove those
<weaksauc_>
something about \\ being at the start causes an issue
<leftylink>
> The backslash character \ can be used to escape ^ or - and is otherwise ignored unless it appears at the end of a sequence or the end of a other_str.
<leftylink>
I can lead the horse to water, but I can't make it drink
<henk>
it’s used to remove the backslashes in the regex escaping 'A' and 'z' to make them anchors and just leaving them out means they are kept in the regex while the thing they escape (A and z) are removed, breaking the regex …
<henk>
leftylink: IIUC you are currently testing one case that’s still a bit unclear, correct? or are those commands that should make things clearer for me? because this seems to be the one case I still don’t understand … all other variants mentioned seem clear now.
<henk>
uuuuh
<henk>
o_O that seems strange, to say the least … WTF? not even sure what to ask :D
<leftylink>
I don't really like it, but I didn't make the rules
<henk>
ok, so we have working: 'Az\\', 'A\\\z', and '\\\Az'
<henk>
and non-working: 'Az\\\', 'A\\z', and '\\Az'
otisolsen70 has quit [Quit: Leaving]
<henk>
that doesn’t seem to make sense and not really match the description, does it? seems like a bug to me. at least in the docs that they don’t warn about this properly, right?
<leftylink>
the docs were wrong to say that it is ignored. they should have instead simply said that \ is the escape character, full stop.
<leftylink>
it's worse when you have to contend with escape sequences in both the language level (in the string literal) and in the library level (in how the functions interpret a particular sequence of character). but I suppose using single quotes is helping not make mistakes in the former
<henk>
well, yes, better, but it’s still not comprehensive and coherent …
<henk>
it’s not clear why '\\Az' does not work and '\\\Az' does … or in other words, taking examples from the linked docs: why does "hello\r\nworld".delete("\\r") remove the single r, but not the escaped r and not the backslashes? why does "hello\r\nworld".delete("\\\r") remove the \r but not the backslash of \n?
<leftylink>
because there is not "a backslash of \n"
<leftylink>
there is a newline character
<leftylink>
"hello\r\nworld" does not contain any backslashes.
<leftylink>
when delete sees \Az, it says delete two characters: the character designated by the escape sequence \A, and the character z
<leftylink>
the character designated by the escape sequence \A is A
<leftylink>
so it deletes A and z, deleting no backslashes
rvalue has quit [Ping timeout: 268 seconds]
<leftylink>
with .delete('\\\Az'), delete sees \\Az, so it will delete three characters: the character designated by the escape sequence \\, A, and z. the character designated by the escape sequence \\ is \, so it deletes backslashes, A, and z
<leftylink>
pandabot rb [src = /\A\z/.source, a = '\\Az', src.delete(a), b = '\\\Az', src.delete(b)].map(&:chars)